How to find the index of specific word?

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
royF
Posts: 13
Joined: Mon Oct 10, 2022 10:48 pm

How to find the index of specific word?

Post by royF » Thu Oct 13, 2022 9:18 pm

How to find the index (number) of specific word?

Code: Select all

put any word of "Easy Medium Hard Extreme" into game_level
answer the num of the word game_level of "Easy Medium Hard Extreme"  ----> Don't work!

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to find the index of specific word?

Post by Klaus » Thu Oct 13, 2022 9:28 pm

Hi royF,

use OFFSET for something like this, and here especially -> WORDOFFSET

Code: Select all

...
## Save typing by putting this string into a variable!
put "Easy Medium Hard Extreme" into tLevels
put any word of tLevels into game_level
put wordoffset(game_level,tLevels) into tNumOfWord
answer tNumOfWord
...
Check also "wholematches" in the dictioanry, important for any kind of OFFSET.

We also have itemoffset, offset (= character offset), lineoffset and some more.
Enter OFFSET in the dictionary to see all of them.

Best

Klaus

royF
Posts: 13
Joined: Mon Oct 10, 2022 10:48 pm

Re: How to find the index of specific word?

Post by royF » Thu Oct 13, 2022 9:33 pm

Amazing! Thanks!!

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”