[SOLVED] A syntax error I can't get right

Started by cybermind, July 29, 2013, 06:31:27 AM

Previous topic - Next topic

cybermind

In this piece of code the compiler tells me that there are a syntax error in the "IF" line at top, I can't see why? I remove most of the conditions and leaving only a few in that line it goes past that and tells me that there are a syntax error in "give_items = 0", I am puzzled :-P (NOTE: This is code from something I previously coded in DarkBASIC Professionel).

if action_activated = 1 and show_event = 1 and show_list = 0 and in_game_menu = 0 and items_required_not_in_possession = 1 and give_items = 0 and required_items = 0 and take_items = 0 and encounter_at_this_sub_entry = 0 and skill_using = 0 and action_single_press = 0
`mark that current sub entry is completed
if fled_from_battle = 0 then conversations_completed(event,sub_entry) = 1
action_single_press = 1
give_items = 0
required_items = 0
take_items = 0
show_event = 0
event = 0
skill_required = 0
skill_given = 0
skill_success = 0
skill_using = 0
fled_from_battle = 0
sub_entry = 1
encounter_at_this_sub_entry = 0
random_encounter_timer = timer_stored + pause_random_encounter_timer
items_required_not_in_possession = 0
endif

kevin

#1
  works here, but as i remove this line     if fled_from_battle = 0 then conversations_completed(event,sub_entry) = 1   , since it's accessing an array that isn't previously declared in the snippet.   




cybermind

I used some of the variables names as labels also :-P Thank you for time! It is invaluable to me that people will use their time for so small problems :-)

kevin


Yeah, that won't work.   Will have a look at improving the error though, since Syntax is too generic.

All keyword names have an order precedence in PlayBASIC, with the highest being Function/Psub followed by Label names, since they're resolved during Pass#1,  the others only exist during Pass#2.  From memory TYPE names have precedence over Variable/Arrays names.


some examples for others reading this in the future:


PlayBASIC Code: [Select]
   ; this can't be called stuff, since Stuff already exists as function
Dim Stuff(100)


Function Stuff(a)

EndFunction





PlayBASIC Code: [Select]
    ; Attempting to create a variable called WOMBAT will fail
; since the WOMBAT keyword is already defined as a LABEL during pass#1

Wombat = 45


end



; define subroutine called WOMBAT starting point

Wombat:
print "This is the Wombat sub-routine"
return






cybermind

Just a note, I actually think that the labels were remmed out at the time of the syntax error. I will try and recreate the scenario if it is of any help to you :-)

kevin

#5
   Yep that would also fail.  Pass #1 doesn't actually look at syntax it's only looking for markers, namely labels and function/psub prototypes.    Meaning it's entirely possible for a label / function name to be seen inside a remark block, since rems (ie the syntax) are only parsed during Pass #2.     It's been on the to-do list for a while..  It's should be possible to implement something to catch rems during pass #1, but that wouldn't work for directives like this,


PlayBASIC Code: [Select]
   Constant RemoveFunctions =true

#if RemoveFunctions =true

Function HelloWorld()


EndFunction

#Endif





   Edit:  Remark block parsing has been added to PlayBASIC V1.64O