script edit return constant

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
elagattolla
Posts: 2
Joined: Mon Jan 16, 2012 9:20 am

script edit return constant

Post by elagattolla » Mon Jan 16, 2012 9:32 am

What is the proper grammar for entering a return constant line break? I am trying to enter variables into a field. I want one line followed by another, therefore it seems return is what I am looking for. I am trying to illustrate the greatest common divisor algorithm. This is what I have so far:
put 673 into m
put 12 into n
--673 and 12 could be any numbers
put m & comma & n into field "Field"
--I want 673,12 to be displayed so the users know what numbers we are finding the greatest common divisor of
put return after item 2 of field "Field"
--so this is the part that is wrong. Whatever I put next just replaces the 673,12 instead of being on the next line.
--then I want to do m mod n to find the remainder and proceed with the algorithm

I hope I explained my issue correctly. Thanks a bunch.

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

Re: script edit return constant

Post by Mark » Mon Jan 16, 2012 11:22 am

Hi,

So, where's the syntax that "puts next"? In the syntax you posted, I see no mistakes.

Kind 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

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm

Re: script edit return constant

Post by kdjanz » Mon Jan 16, 2012 3:47 pm

I think what you want to do is to now

Code: Select all

put return AFTER field 1
...
put divisor & return after field 1
After will put it at the end of the field and create a new line, then you can display your divisor on the next line and continue on that way.

Hope I'm understanding correctly,

Kelly

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: script edit return constant

Post by sturgis » Mon Jan 16, 2012 4:01 pm

If you start with an empty field

put empty into field "myfield"

Then want to cycle through a bunch of numbers and build up a sequence of lines use the "after" form of put as mentioned above.

put m & comma & n & return after field "myField"


This way it will append whatever you are 'put'ting AFTER the end of the field.

Then when done putting all your lines in you'll want to "delete the last char of field "myField" to get rid of the dangling return.

Another method would be to ignore the field while processing is done and build your list of lines in a variable.

put m & comma & n & return into tMyTempVariable


When done processing all your numbers,
delete the last char of tMyTempVariable
put tMyTempVariable into field "myField" -- since we're wanting to put the whole contents of the variable into the field intact, use into rather than after

If there will be lots of lines and processing to be done, using a temp variable to hold the work in progress will be faster than working directly with the field.

elagattolla
Posts: 2
Joined: Mon Jan 16, 2012 9:20 am

Re: script edit return constant

Post by elagattolla » Mon Jan 16, 2012 10:28 pm

Many thanks for the insight!

Post Reply