[Solved] OOo BASIC syntax issue: unexpected symbols

Creating a macro - Writing a Script - Using the API

[Solved] OOo BASIC syntax issue: unexpected symbols

Postby jones172 » Sat Jul 10, 2010 11:30 pm

From Tom:

Under ooBASIC in a spreadsheet, I keep getting an error message saying,
"BASIC syntax error
Unexpected symbol (
-----------------------------
Above is end of error message. See below for the location of the error message.
(snip)
-------------------------------------
Code: Select all   Expand viewCollapse view
Function run_one_char (chars As String) As Long
Dim first_char As Long
Dim first_char_2 As Long
first_char = CLng (Asc (chars))
REM Print "first_char =", first_char
first_char_2 = first_char * first_char
REM Print "first_char_2 ", first_char_2
run_one_char = first_char_2
Exit Function
End Function
REM The error message arrow is beside
REM (Accepted value as String
Function TLU1_
(Accepted_value As String, _
NotFound As Boolean) As Long
Dim ans1 As Long, ptr As Long,LoopBreaker As Long
ans1 = char_hash1 (accepted_value)
ptr = ans1 MOD NBrandTab
print "Accepted_value = ", Accepted_value
print "ptr = ", ptr

MainLoop:
If (BrandTab (ptr) = "") Then
TLU1 = ptr
NotFound = True
EndIf
REM BrandTab entry not = ""
REM Slot not empty

If (Accepted_value = BrandTab (ptr)) Then
TLU1 = ptr
NotFound = False
Exit Function
EndIf

REM No match but slot not empty
REM Either collision or just not found

REM Scan down and look for match
ptr = ptr  + 1
ptr = ptr MOD NBrandTab
LoopBreaker = LoopBreaker + 1
If (LoopBreaker >= NBrandTab) Then
print ("LoopBreaker error")
Stop
EndIf

GoTo MainLoop
End Function
(snip)

------------------------------------------
End of file

From Tom:
ooOrg 3.2.1
Win XP Home SP3

Your advice?
Last edited by jones172 on Sun Jul 11, 2010 7:47 pm, edited 1 time in total.
jones172
 
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am

Re: ooBASIC syntax issue--unexpected symbols

Postby FJCC » Sun Jul 11, 2010 2:18 am

Try putting a space after TLU1 and before the underscore in the function name
Code: Select all   Expand viewCollapse view
Function TLU1 _

I think the underscore is being interpreted as part of the function name.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7013
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: ooBASIC syntax issue--unexpected symbols

Postby jones172 » Sun Jul 11, 2010 3:27 am

No, I'm afraid not. All it will says is, Error, TLU1 already defined differently.

Incidentally, this macro, TLU1, is new and may well have some bugs in it.

What's next, pull TLU1 all of the way out, write drivers, and run tests on it as a separate program? I wonder if even that would work.
jones172
 
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am

Re: ooBASIC syntax issue--unexpected symbols

Postby FJCC » Sun Jul 11, 2010 3:49 am

Adding the space between the function name and the underscore got rid of the error when I copied that part of the code into my own document. The fact that you are getting a new error probably means you are making progress. Somewhere else in the code TLU1 is probably being interpreted as a variable. I would look at every occurrence of it and check the syntax there.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7013
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: ooBASIC syntax issue--unexpected symbols

Postby Zizi64 » Sun Jul 11, 2010 8:07 am

The "underscore" character indicates that the line of code is too long, it must be broken, and the next line will continue. (when "Undercore" located at end of line.)

Never use "space" character (or other special characters) in a function name, or in a name of variable. Do not use the "underscore" character at the end of names (as part of name).
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.5 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.0 and AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7702
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: ooBASIC syntax issue--unexpected symbols

Postby jones172 » Sun Jul 11, 2010 7:41 pm

The problem was that I had a defective function call. The function has two parameters, and the function call had only one parameter.

Thank you!

Tom
jones172
 
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests