Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Zlatko Vid on April 18, 2023, 11:08:15 AM

Title: SELECT string
Post by: Zlatko Vid on April 18, 2023, 11:08:15 AM
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!"
Title: Re: SELECT string
Post by: Charles Pegge on April 18, 2023, 06:33:02 PM
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
Title: Re: SELECT string
Post by: Zlatko Vid on April 18, 2023, 07:49:21 PM
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
Title: Re: SELECT string
Post by: Nicola on April 21, 2023, 07:45:29 PM
Hi,
I put this note with the example in the Help file, in the SELECT topic.
;)
Title: Re: SELECT string
Post by: Zlatko Vid on April 22, 2023, 09:02:15 PM
Yes ..that would be nice !