[Solved] OOo BASIC syntax issue: unexpected symbols

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
jones172
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am

[Solved] OOo BASIC syntax issue: unexpected symbols

Post by jones172 »

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

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.
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: ooBASIC syntax issue--unexpected symbols

Post by FJCC »

Try putting a space after TLU1 and before the underscore in the function name

Code: Select all

Function TLU1 _
I think the underscore is being interpreted as part of the function name.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
jones172
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am

Re: ooBASIC syntax issue--unexpected symbols

Post by jones172 »

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.
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: ooBASIC syntax issue--unexpected symbols

Post by FJCC »

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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: ooBASIC syntax issue--unexpected symbols

Post by Zizi64 »

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; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
jones172
Posts: 85
Joined: Tue Apr 22, 2008 1:56 am

Re: ooBASIC syntax issue--unexpected symbols

Post by jones172 »

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
Post Reply