finding a string in a global variable

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

finding a string in a global variable

Post by Glenn Boyce » Fri Aug 22, 2008 2:03 am

I 've put some customer data into a global variable and was hoping to use the find and get foundline functions to retrieve specific items from a "find" done on customer name. It works in a field. how do I make it work in a gVariable?

thanks, Glenn

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Fri Aug 22, 2008 10:38 am

Hi Glenn,

you can use "offset" or "contains" (and maybe more :-))!

Code: Select all

...
if tGlobalVar contains "My string" then
  ## string is in global
end if
...
"offset" will return 0 if your string is not in the global and a number (position of the first char of your string in the global) if the global contains your string.
...
if offset("My string",tGlobalVar) <> 0 then
## string is in global
end if
...

Best

Klaus

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Post by Glenn Boyce » Mon Aug 25, 2008 12:01 am

Hi Klaus,

Thanks for that. I need the line number of the string. Is that what is returned?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Mon Aug 25, 2008 8:45 am

Hi Glen,

ah, sorry, overlooked that.

Then you can use "lineoffset", which will give you the linenumber of your desired string(s).


Best

Klaus

Post Reply