Setting a field equal to a variable

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

Post Reply
bqsbarbqGAnC5Z
Posts: 77
Joined: Thu Dec 08, 2011 12:19 pm

Setting a field equal to a variable

Post by bqsbarbqGAnC5Z » Thu Apr 05, 2012 7:46 am

Hi everyone,

I have two fields on my card and was wondering if there was any way to get the fields to show a variable that I have defined. I want one of the fields to show the variable itself and the other field to show the variable - 50. I tried using

set field "fieldname" to sVariableName
set field "fieldname" to sVariableName - 50

but I got no success with this and the script wouldnt even run. Does anyone have any suggestions. Any help is much appreciated. Thank you!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Setting a field equal to a variable

Post by bn » Thu Apr 05, 2012 8:20 am

Hi,

try:

Code: Select all

put sVariableName into field "fieldName"
put sVariableName - 50 into field "fieldName"
you would use the "set some property to some value" only on properties, otherwise you use the "put something into something" syntax.

in your case:
field "fieldName" is a container, you put things into containers.

the borderwidth of field "fieldName" is a property. you would "set the borderwidth of field "fieldName" to tVariable.

It might be a bit confusing but you will get a feeling for when to use which form.


Kind regards

Bernd

bqsbarbqGAnC5Z
Posts: 77
Joined: Thu Dec 08, 2011 12:19 pm

Re: Setting a field equal to a variable

Post by bqsbarbqGAnC5Z » Sat Apr 07, 2012 9:17 am

That worked perfect, thanks BN!

Post Reply