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
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Sat Oct 31, 2020 12:30 pm
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:
Code: Select all
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
Any hints appreciated.
Kaveh
-
Attachments
-
- return.livecode.zip
- (1.37 KiB) Downloaded 244 times
Kaveh
-
Klaus
- Posts: 14193
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sat Oct 31, 2020 1:29 pm
Hi Kaveh,
the closest I could get was this:
Code: Select all
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:
Code: Select all
...
put tOne & value(tTwo) & tThree into tFive
...
Best
Klaus
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Sat Oct 31, 2020 1:52 pm
Hi Klaus
You have solved my problem! I never used
value( ). I have now introduced a loop similar to this in my script:
Code: Select all
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
and it works.
Great weekend ahead, thanks to you.
Kaveh
Kaveh
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Oct 31, 2020 6:43 pm
Kaveh.
What am I missing here?:
Code: Select all
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.
What did I miss?
Craig
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Sat Oct 31, 2020 6:53 pm
Hi Craig
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.
In the bottom right field?
Kaveh
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Oct 31, 2020 8:04 pm
Keveh.
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".
Craig
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Sat Oct 31, 2020 8:42 pm
Hi Craig
I appreciate your questions on this and they are very good ones! I can tell you what I am doing. Please see this thread:
viewtopic.php?f=8&t=34799
I am using the revXML library to analyse and hopefully modify complex XML files. As an example pls search for
Code: Select all
put revXMLTree(106,"/",return,space,true,-1) into tTree
on this page:
https://livecode.com/docs/9-5-0/core-co ... -data/#xml
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.

-
Attachments
-

Kaveh
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Nov 02, 2020 5:00 am
Hi.
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:
Code: Select all
on mouseUp
do "put fld" && quote & "one" & quote && "&" && fld "two" && "&" && "fld" && quote & "three" & quote && "into fld" && quote & "four" & quote
end mouseUp
Rethink, rethink, rethink.
Craig