How to code if a certain field has content go to another fid

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
timbrian
Posts: 6
Joined: Sat Jan 17, 2015 12:51 am

How to code if a certain field has content go to another fid

Post by timbrian » Tue Aug 04, 2015 7:46 pm

I have used an options menu which has 8 options to it.

I have 6 fields where i want to put the menu choice output.
Fields a,b,c,d,e,f

I want the first choice from the options menu to output into field "a" ( i got this part to work)
then I want the script to be able to recognize content in field "a" and output the second menu choice
into field "b" etc.

this is what i have written but it is not working.

on menuPick pItemName
switch pItemName
case "choice1"
put "AA" into field "a"
if the contents of field "a" = "true" then (true-meaning it contains output)
put "AB" into field "b"
end if
end switch
end menuPick

Just looking to be pointed in the right direction!
Tim
Louisville, Ky

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to code if a certain field has content go to another

Post by Klaus » Tue Aug 04, 2015 8:27 pm

Hi Tim,

not sure, but maybe you mean:

Code: Select all

...
if fld xyz <> empty then
  ## Do this and that...
end if
...
?

Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: How to code if a certain field has content go to another

Post by dunbarx » Tue Aug 04, 2015 8:31 pm

Hi.

You are on your way, so I am going to let you keep going.

Note though, that when you say:

Code: Select all

if the contents of field "a" = "true" then (true-meaning it contains output)
This is will not work. First, there is no native word "contents". What you really wanted was:

Code: Select all

if field "a" = "true" then --(true-meaning it contains output)
The contents of a field is the text property of that field, (implied above, and valid) so you could also have said:

Code: Select all

if the text of field "a" = "true" then --(true-meaning it contains output)
Second, "true" is a literal, and is the string "true". What you really wanted was to either check for the actual contents, or perhaps that the text was not empty:

Code: Select all

if field "a" = "AA" then
or
if field "a" <> empty then
You can also extract the contents of the option button into a return delimited list (this is how it is organized anyway) and run a short repeat loop that will load successive lines of the button contents into successive fields.

All loads of fun. Write back with your progress.

Craig Newman

Post Reply