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!
I have a stack where I have to construct a command, then execute it. A parameter in the command can be a tab or a return. But whatever I do these are treated as verbatim "return" or "tab".
To illustrate it I attach a minimal stack. There is just one script, in the "Do it" button:
on mouseup
put fld "One" into tOne
put fld "Two" into tTwo
put fld "Three" into tThree
put "put tOne & tTwo & tThree into fld" && quote & "Four" & quote into tCommand
do tCommand
end mouseup
What I need is to have the following in field "Four": One
Three
on mouseup
put fld "One" into tOne
put fld "Two" into tTwo
put fld "Three" into tThree
put value(tOne) & value(tTwo) & value(tThree) into tFive
put "put tFive into fld" && quote & "Four" & quote into tCommand
do tCommand
end mouseup
Will end with:
1
3
in field "Four" however.
If the TAB or RETURN is always in fld "Two" then this should do:
repeat with i = 1 to the number of items of sOptions
if value(item i of sOptions) is "return" then
put "return" into item i of sOptions
end if
if value(item i of sOptions) is "tab" then
put "tab" into item i of sOptions
end if
end repeat
on mouseUp
put fld "one" & return & fld "three" into fld "four"
end mouseUp
I am an old diehard with using "do" as a method of double evaluating a string. This is an old, old trick and is the only way out of certain dilemmas. But I do not see any need for it here, nor the use of the "value" function.
Now this is only a prelude to telling you never to name controls with reserved words, like "three", especially if those words can be interpreted by LC as numbers. Use 'fThree" instead.
I take your point about naming of fields. I always use "t", "s" and "g" for variables, but never thought of "f" for field.
Regarding the "do" workaround, the problem is a big stack that I will not post here as it has a lot of irrelevant material. So I created the minimal stack to illustrate the problem. Is there another way of getting what I want, i.e.
OK. Now I see. You had the string "return" in field "two", and wanted to form that, er, forgive me, mess, into an executable string.
This is the moment when one rethinks what one has wrought in the first place, and rewrite into something, er, forgive me, more sane.
Is there really a compelling reason to assemble the contents of those fields into something LC can understand? I cannot imagine one, but do tell me if there is.
But I can imagine a situation where the user places values into fields "one" and "three", and then you supply the "return" or "after", whatever, in fld "two".
I want to have an interface to put in the values for these parameters. These include return, space, and tab. As an example pls see snippet of interface attached.
So I am constructing the revXML... commands from the data in the interface. And the problem I am having is the "return", "tab" etc not behaving correctly.
I hope that makes it a bit clearer but happy to hear any more suggestions. Always a great place to learn here for me.
Purely for the fun of it, I made the four fields you posted, named "one, "two", "three" and "four", with "one" in fld "one", "return" in fld "two" and "three" in fld "three". Field "four" was empty.
Don't use this naming scheme ever again.
I put this in a button script, for no good reason other than that I like to use "do" constructions now and then: