Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Function declaration not accepted / var. not dimensioned/ Lo

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR old unsupported versions
View previous topic :: View next topic  
Author Message
autoguider

Bascom Member



Joined: 24 Sep 2007
Posts: 82
Location: Aachen

germany.gif
PostPosted: Mon Nov 21, 2022 9:52 pm    Post subject: Function declaration not accepted / var. not dimensioned/ Lo Reply with quote

Dear All,

I declared a funtion that has no parameters and returns a byte
Code:
Declare Function Is_new_process As Byte  


Here the code of the function


Code:

 Function Is_new_process As Byte
       Local Mybyte As Byte


       If Exposure_paused_pin = 0 Then
          B_exposure_paused = True
         Else
         B_exposure_paused = False
       End If

       If B_exposure_paused_old = False And B_exposure_paused = True Then

         B_temp_byte = True
         B_exposure_paused_old = True
       End If


       If B_exposure_paused_remote = True Then

          B_exposure_paused_remote = False
          B_exposure_paused_old = True
          Mybyte = True

       End If

       Is_new_process = Mybyte Or B_temp_byte


 End Function
 


Now calling the function

Code:
  Dim Xbyte As Byte

  Call StringEval
Xbyte = Is_new_process
  If B_temp_byte = True Then
      Call Start_ir
  End If
 

I get 2 error messages and even after studying the docs I do not know what I did wrong.
Error : 93 Line : 662 Variable not dimensioned [IS_NEW_PROCESS] , in File : D:\Schubi_Stick\motcntrl20221118.bas

As far as I know locals are allowed in functions and subs
Error : 114 Line : 1411 LOCAL only allowed in SUB or FUNCTION [MYBYTE AS BYTE] , in File : D:\Schubi_Stick\motcntrl20221118.bas
when I write Function Is_new_process without the As byte in the head of the function the error message does not pop up

I kindly ask for advice.
kind regards
Christian

(BASCOM-AVR version : 2.0.8.3 , Latest : 2.0.8.5 )
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1133

poland.gif
PostPosted: Mon Nov 21, 2022 11:37 pm    Post subject: Reply with quote

It compile just fine.
Nex time please attach code that can be compiled by simply copy/paste...and remember about brackets.
I also suggest update your Bascom because your version may be not supported Very Happy

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 64
$swstack = 16
$framesize = 64

Config Submode = New

Const True = 1
Const False = 0

Dim B_exposure_paused As Byte
Dim B_exposure_paused_old As Byte
Dim B_temp_byte As Byte
Dim B_exposure_paused_remote As Byte
Dim Xbyte As Byte

Exposure_paused_pin Alias Pinb.0

Sub Stringeval

End Sub

Sub Start_ir

End Sub


Function Is_new_process() As Byte
   Local Mybyte As Byte


    If Exposure_paused_pin = 0 Then
       B_exposure_paused = True
      Else
      B_exposure_paused = False
    End If

    If B_exposure_paused_old = False And B_exposure_paused = True Then

      B_temp_byte = True
      B_exposure_paused_old = True
    End If


    If B_exposure_paused_remote = True Then

       B_exposure_paused_remote = False
       B_exposure_paused_old = True
       Mybyte = True

    End If

    Is_new_process = Mybyte Or B_temp_byte

End Function

Call Stringeval

Xbyte = Is_new_process()

If B_temp_byte = True Then
   Call Start_ir
End If

End
 
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Mon Nov 21, 2022 11:49 pm    Post subject: Reply with quote

I would complete the function with empty braces.
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1133

poland.gif
PostPosted: Tue Nov 22, 2022 12:05 am    Post subject: Reply with quote

That code had one more flaw.
This probably was from some copying.
If Bascom shows strange errors then you should check copied code in some Notepad++ for incorrect encoding or invisible characters.



So...here you have CRLF but after some weird space. Comment line before the last "END" and code probably compile Wink



BTW. Bascom also have option for that ->Option->Environment->Show Special Characters but maybe this will not be so visible for the first look.

Back to top
View user's profile Visit poster's website
autoguider

Bascom Member



Joined: 24 Sep 2007
Posts: 82
Location: Aachen

germany.gif
PostPosted: Tue Nov 22, 2022 2:41 pm    Post subject: Reply with quote

Many thanks for your advice.

In Options>Environment-> Font I found the checkbox to show the special characters.
With your advised corrections I was able to get a compilation.

So far so good but now I am facing another problem which seems to be caused by Copying and /pasting data from the Windows editor

I made the strange experience that BASCOM starts up the opening process of the file that I edited yesterday.
I see a BASCOM fileeditor window opened and a green progress bar in the IDE bottom section.
Then the IDE disappears without any message/ comment.

So I have no other choice but to open the file in the editor, copy the code and paste it into a new BASCOM file.
Then it compiles fine.
I save it.
When reopening I face the problem as described above. Opening starts, progress bar long and green and the the application is closed without any warning/ message.

I can create a new file in BASCOM, save it, close it and reopen it.

When pasting some code from another file that was opened in the BASCOM environment save and close it reopening runs well.

When pasting some code from another file file that I opened in the Windows editor I can save it but reopening it fails.


Further investigation:
When creating the new file in the IDE and having the option for the special characters activated the new file contains a lot of EOF characters only.
After pasting, even of a few lines only, I do not see any EOF.

The long progress bar when loading is suspicious. maybe BASCOM does not find an EOF.


Is there an intereference to VisualBasic (VisualStudio 2019) that I have also on my computer?

I keep on trying to copy from the editor function by function.
Do you have some idea what to do?

Thx again
Christian
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1133

poland.gif
PostPosted: Tue Nov 22, 2022 8:50 pm    Post subject: Reply with quote

Maybe you should start with update your Bascom.
Download 2085 installer and install it in new folder.
I always do that and have previous for "some reasons"
Here I have "only" from 2082 because i change my computer.



Bascom from some version create separate XML file that can sometimes fix your Bascom installation.

In Bascom IDE you find ->Help ->About ->App data dir.
If you click that link then folder should open and then you must close entire Bascom because those files are keept in the memory and resaved on Bascom close.



So if Bascom is closed then rename your XML into something else like "___bascom-avr2083.xml"
Then if you reopen Bascom then it should be like new.
If that not help then you probably must search problem in your PC.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR old unsupported versions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum