PDA

View Full Version : Example: Using LUA's string.find & Character Ranges


Intrigued
11-07-2005, 07:56 PM
Have you found a time when you needed to check for a certain number between a range of numbers? Say for example you want to see if a variable in your program (that changes often) is between say once (1) and eight (8)? Well, here is an example on how you can check such variable:

-- First define a variable to hold a random number to check against
n = 5

-- Note 'string.find' is all lower-case! It's a LUA function (not AMS created)
result = string.find(n, '[1-8]')

--[[
If there is an instance of '5' between 1 and 8, then show confirmation.
otherwise, show the second (no instances found) dialog. This is a good way
to easily check a "range" of numbers! Forum member TJ_Tigger first alerted us to this LUA innate function. Remember, type 'string.find' in all lower-case or the function will not work!
]]
if result then
Dialog.Message("", "Found at least one instance!")
else
Dialog.Message("", "Did not find any instances!")
end

SiNisTer
05-03-2007, 02:20 AM
Finally - Something that resembles what I need to do in my project:D .
Intrigued, I have a problem.I'm currently working on an audio player, and i need help. its a problem between a listbox and an input object.

What I need to do is this:
When a user types in anything in the input box, i want that track to be selected automatically as the user types - in the end displaying (i.e:selecting) the most accurate result...I hope Ive made my problem clear so far mate..
For example, Lets assume that there are audio tracks in a list box as follows
1)Aerosmith - Jaded
Aerosmith -
Body Rockers - I Like the way you move
Rascall Flatts-life is a highway
etc,etc....

Getting Back:
When the user types:
"Aerosmith" - My app should automatically select that track, but if the user types "1)Aerosmith" then the selection should jump to this track...& if the User Simply types "I Like the way you move" then this track should be selected...In short - the most appropriate result should be selected

I hope that my problem has been highlighted clearly and i really really hope you or any other expert could help me out here...

>I know this is a lengthy reply but excuse me for that< :lol

Once again, Pls help:o

Thanx

bule
05-03-2007, 04:18 AM
Where do you keep your playlist?
Are you using a table or something else?

CrazyFrog
05-03-2007, 04:49 AM
Nice Work , Intrigued ! I hope this will help me a lot ! , Thanks

SiNisTer
05-03-2007, 11:59 PM
Where do you keep your playlist?
Are you using a table or something else?


I keep my playlist in a listbox ("Playlist1")...

SiNisTer
05-06-2007, 08:05 AM
Hey Guys dont give up on me already:rolleyes ...I really wish someone could assist me here...