Syntax Error

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
pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Syntax Error

Post by pwr » Thu Apr 30, 2009 2:12 am

For my first Revolution app I have the user select text from a field and the selected text displays in another field. Although this is simple enough, the selected text may use the textShift property to sub- or superscript certain characters.

Since I wanted the selected text to display in the other field correctly I used the following script to search for textShift so as to correctly display the selectedText in the second field...

on selectionChanged
--update the input unit label with the selected input unit
put the selectedText of me into field "fldSelectedInputUnit"
--test code to put in sub- and superscript
repeat with i = 1 to the number of chars in selectedText of me
if the textShift of char i of selectedText of me is not empty then
get the textShift of char i of selectedText of me
set the textShift of char i of field "fldSelectedInputUnit" to it
end if
end repeat
--end test code
--check to see that the needed data is available
--and re-calculate unit conversion
if the text of field "fldSelectedInputUnit" is not empty then
if the text of field "fldSelectedOutputUnit" is not empty then
if the text of field "fldInputValue" is a number then
ConvertUnits
end if
end if
end if
end selectionChanged

However, although the compiler has no complaints, I get a runtime error on the highlighted line. The error msg is:

field "fldInputUnits": execution error at line 7 (Chunk: can't find object), char 24

Can anyone help me correct my syntax??? Thanks in advance...pwr

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Apr 30, 2009 8:11 am

Dear pwr,

The selectedText is only a reference to text, not a reference to an object. You might want to use the selectedChunk instead.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply