check reserved word

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lbtony
Posts: 35
Joined: Tue Apr 11, 2006 9:01 am

check reserved word

Post by lbtony » Tue Apr 25, 2006 9:21 am

I have a field and a button. I want to allow user to input something in the field then click on the button, then the program will decide whether the string entered in the field is a keyword in runrev. Anybody know how to do this??

[/code]

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Tue Apr 25, 2006 10:33 am

Look for "names" in the dictionary part of the docs. For instance,

the commandNames
commandNames()
Returns a list of all built-in commands in Transcript.

the constantNames
constantNames()
Returns a list of all built-in constants in Transcript.

the propertyNames
propertyNames()
Returns a list of all built-in properties in Transcript.

the functionNames
functionNames()
Returns a list of all built-in functions in Transcript.

To use them, simply write:

Code: Select all

on mouseup
     put the text of field "myfield" into tString
     if isReservedWord(tString) is true then 
         ......
    end if
end mouseup
function isReservedWord pString
	if pString is among the lines of the commandnames then return true
	if pString is among the lines of the constantnames then return true
	if pString is among the lines of the functionnames then return true
	if pString is among the lines of the propertynames then return true
	return false
end isReservedWord

lbtony
Posts: 35
Joined: Tue Apr 11, 2006 9:01 am

Post by lbtony » Tue Apr 25, 2006 1:16 pm

Thank you. :P

Post Reply