Discussion forum for the BasicX family of microcontroller chips.
Syntax Error in Call Delay(0.5) in String Procedure - morenovrichard - Dec 19 7:08:38 2006
Why does the following procedure produce a syntax error? Any idea
anyone. Thank-you for your time!
Option Explicit
Dim OutputBuffer(1 To 30) As Byte
Dim InputBuffer(1 To 13) As Byte
Public CreateFile(ByVal FileName As String)
Call Delay(0.5) <-------------------- Syntax Error (?...)
Call OpenQueue(OutputBuffer, 30)
Call OpenQueue(InputBuffer, 13)
Call DefineCom3(6,5,bx0000_1000)
Call OpenCom(3, 9600, InputBuffer, OutputBuffer)
Call PutQueueStr(OutputBuffer, FileName)
Call PutQueueStr(OutputBuffer, chr(13) & chr(10))
End Sub

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Syntax Error in Call Delay(0.5) in String Procedure - Tom Becker - Dec 19 10:00:13 2006
> Public CreateFile(ByVal FileName As String)
>
> Call Delay(0.5) <-------------------- Syntax Error (?...)
I think your error is in the previous line, which should be Public Sub
CreateFile [...]. I think you defined a string named CreateFile, but
that syntax would be odd, too.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Syntax Error in Call Delay(0.5) in String Procedure - Mike Perks - Dec 19 10:01:25 2006
morenovrichard wrote:
Public _*Sub*_ CreateFile(ByVal FileName As String)
[Non-text portions of this message have been removed]

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Syntax Error in Call Delay(0.5) in String Procedure - Chris Odom - Dec 19 10:10:59 2006
You have several mistakes:
Most important, your program needs a Main procedure. Add the lines:
Public Sub Main()
Call CreateFile( << File Name here >> )
End Sub
Also, you need the word "Sub" in your procedure declaration:
Public Sub CreateFile(ByVal FileName As String)
NOT: Public CreateFile(ByVal FileName As String)
If you have a copy of my book, I discuss procedures and functions in
Chapter 12.
chris
--- In b...@yahoogroups.com, "morenovrichard"
wrote:
>
> Why does the following procedure produce a syntax error? Any idea
> anyone. Thank-you for your time!
>
> Option Explicit
>
> Dim OutputBuffer(1 To 30) As Byte
> Dim InputBuffer(1 To 13) As Byte
>
> Public CreateFile(ByVal FileName As String)
>
> Call Delay(0.5) <-------------------- Syntax Error (?...)
>
> Call OpenQueue(OutputBuffer, 30)
> Call OpenQueue(InputBuffer, 13)
>
> Call DefineCom3(6,5,bx0000_1000)
> Call OpenCom(3, 9600, InputBuffer, OutputBuffer)
>
> Call PutQueueStr(OutputBuffer, FileName)
> Call PutQueueStr(OutputBuffer, chr(13) & chr(10))
>
> End Sub
>

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Syntax Error in Call Delay(0.5) in String Procedure - benoit_bleau1 - Dec 19 10:17:56 2006
This looks like a bug in the compiler. This same code in the Main sub
compiles fine:
Option Explicit
Dim OutputBuffer(1 To 30) As Byte
Dim InputBuffer(1 To 13) As Byte
Dim FileName As String
Public Sub Main()
Call Delay(0.5)
Call OpenQueue(OutputBuffer, 30)
Call OpenQueue(InputBuffer, 13)
Call DefineCom3(6,5,bx0000_1000)
Call OpenCom(3, 9600, InputBuffer, OutputBuffer)
Call PutQueueStr(OutputBuffer, FileName)
Call PutQueueStr(OutputBuffer, chr(13) & chr(10))
End Sub
Go figure...

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Syntax Error in Call Delay(0.5) in String Procedure - benoit_bleau1 - Dec 19 12:23:33 2006
--- In b...@yahoogroups.com, "benoit_bleau1"
wrote:
>
> This looks like a bug in the compiler. This same code in the Main sub
Darn.... I missed the *SUB*... egg on my face
-Ben

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Syntax Error in Call Delay(0.5) in String Procedure - Don Kirby - Dec 19 17:44:44 2006
> Darn.... I missed the *SUB*... egg on my face
It's a common mistake to leave out or mispell something like that.
For future reference, when the compiler complains about a line of code
that looks correct, comment out that line, and recompile it. Often,
the compiler will narrow down the problem a bit more for you. Also,
try not to concentrate too much on the line that the compiler thinks
is the problem (obviously after you have verified that the line in
question is correct). Look at the preceding and following code for
mistakes as well.
As a side note, there have been compiler bugs in the past that could
cause the compile to fail if there were spaces or other invisible
characters at the end of the line. I don't recall if this has
happened with the BasicX compiler, but it has been known to happen
nonetheless. The fix was usually to simply delete the line and retype
it. Cutting and pasting just pastes the bad characters again, so
retyping is necessary.
Just my $0.02
-Don

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )