return and "return"

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 454
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

return and "return"

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 32 times
Kaveh

Klaus
Posts: 12133
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: return and "return"

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. 8)

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
Livecode Opensource Backer
Posts: 454
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: return and "return"

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
VIP Livecode Opensource Backer
Posts: 7321
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: return and "return"

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
Livecode Opensource Backer
Posts: 454
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: return and "return"

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.

Code: Select all

One
Three
In the bottom right field?
Kaveh

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7321
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: return and "return"

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
Livecode Opensource Backer
Posts: 454
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: return and "return"

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
Screenshot 2020-10-31 at 19.38.38.png
Kaveh

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7321
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: return and "return"

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. 8)

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. :wink:

Craig

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”