Author Topic: String "IF" problem  (Read 2110 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
String "IF" problem
« on: November 25, 2013, 10:08:04 AM »
Hi Charles...
Do you can confirm that quoted string ...like

elseif c$ = "IF"

or

elseif c$ = "ENDIF"

is not detected , or in another words work like it is command IF or ENDIF...
is this a bug or something weird ????

Charles Pegge

  • Guest
Re: String "IF" problem
« Reply #1 on: November 25, 2013, 10:52:55 AM »

Hi Aurel,

String literals are never seen as commands

function f(string a)
if a="if"
  print 1
elseif a="elseif"
  print 2
elseif a="endif"
  print 3
else
  print 4
end if
end function

f "elseif" '2
f "else" '4

Aurel

  • Guest
Re: String "IF" problem
« Reply #2 on: November 25, 2013, 01:30:36 PM »
Thanks Charles...
I do something weird and mess-up my string extract function... ::)

Charles Pegge

  • Guest
Re: String "IF" problem
« Reply #3 on: November 25, 2013, 02:10:10 PM »

Watch out for multi-line strings. I have occasionally failed to close a quoted string, resulting in very strange behaviour. Code becomes string, and string becomes code...

Aurel

  • Guest
Re: String "IF" problem
« Reply #4 on: November 25, 2013, 02:51:30 PM »
Quote
Watch out for multi-line strings. I have occasionally failed to close a quoted string, resulting in very strange behaviour. Code becomes string, and string becomes code...

thanks Charles on advice .. ;)
i will... :)

In my parser i forget to check string without empty space on the end of keyword like
endif...
so i do this :
Code: [Select]
'get position of first empty space ----------
Epos = INSTR (LText," ")
IF EPos <> 0
   'get left from empty space
   c$ = Left(LText,Epos-1)
ELSE
  'get substring argument
  c$= Mid(Ltext,1,Len(Ltext))
END IF
c$ = Trim(c$)
c$=Ucase(c$)

and now work properly.. ;)