SELECT string

Started by Zlatko Vid, April 18, 2023, 11:08:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zlatko Vid

Ouhhh
I find it on old archived forum by JRS(i think that is gone )
so you can try it :

'selection with INT
'string casting -> select/filtering

string s="SELECT_STRING_WITH INTEGER" ' more than 4 chars
'(i AS string pointer)
INT i at strptr s  ' integer pointer cast string s

select i
case "SELECT_STRING_WITH INTEGER"
print "OK..this WORK!"

case "PRINT"
print "OK..just to compare"

    case else
       print " Error : Unknown selection!-> "

end select

print "OK!"

Charles Pegge

Yes!,

I confirm an ascii string can be evaluated as an integer case, up to 4 bytes:

'18/04/2023
'compund ascii
'cased as an int
'
string s="abcd"
int p at strptr s
select p
case "a"
case "ab"
case "abc"
case "abcd"
  print s 'matched
case else
end select

Zlatko Vid

Thanks Charles

In my programming in o2 i really rare use this
because i don't do many large strings (read large number of characters)
processing , i use small cgunks for interpreter and transform them to tokens

also above program work with  SYS p at strptr s
more than 4 chars only as you can see

Nicola

Hi,
I put this note with the example in the Help file, in the SELECT topic.
;)

Zlatko Vid

Yes ..that would be nice !