Referencing a control name

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Referencing a control name

Peter Bogdanoff
Hi all,

I have this data in a field "MyField":

        button "Home",37,26,2,699

I want to reference that data like this:

        set the width of <item 1 of line 1 of field “MyField”> to item 2 of line 1 of field “MyField”

How do I script the stuff inside the <> ? Sometimes that item will be a field, graphic, etc.

Having a brain freeze.

Peter Bogdanoff
UCLA
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

xtalkprogrammer
First put the reference into a variable and then

Set the width of myVar to x

--
Kind regards,

Mark Schonewille
Economy-x-Talk
Http://economy-x-talk.com

Share the clipboard of your computer over a local network with Clipboard Link http://clipboardlink.economy-x-talk.com


Op 25 jul. 2015 om 02:05 heeft Peter Bogdanoff <[hidden email]> het volgende geschreven:

> Hi all,
>
> I have this data in a field "MyField":
>
>    button "Home",37,26,2,699
>
> I want to reference that data like this:
>
>    set the width of <item 1 of line 1 of field “MyField”> to item 2 of line 1 of field “MyField”
>
> How do I script the stuff inside the <> ? Sometimes that item will be a field, graphic, etc.
>
> Having a brain freeze.
>
> Peter Bogdanoff
> UCLA
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Kind regards,

Drs. Mark Schonewille

Economy-x-Talk Consultancy and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Facebook: http://facebook.com/LiveCode.Beginner
KvK: 50277553
Reply | Threaded
Open this post in threaded view
|

RE: Referencing a control name

Ralph DiMola
In reply to this post by Peter Bogdanoff
Also "control" is a synonym for field, button, image.....

Ralph DiMola
IT Director
Evergreen Information Services
[hidden email]


-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf
Of Peter Bogdanoff
Sent: Friday, July 24, 2015 8:06 PM
To: How to use LiveCode
Subject: Referencing a control name

Hi all,

I have this data in a field "MyField":

        button "Home",37,26,2,699

I want to reference that data like this:

        set the width of <item 1 of line 1 of field "MyField"> to item 2 of
line 1 of field "MyField"

How do I script the stuff inside the <> ? Sometimes that item will be a
field, graphic, etc.

Having a brain freeze.

Peter Bogdanoff
UCLA
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Dick Kriesel
In reply to this post by Peter Bogdanoff

> On Jul 24, 2015, at 5:05 PM, Peter Bogdanoff <[hidden email]> wrote:
>
> I want to reference that data like this:
>
> set the width of <item 1 of line 1 of field “MyField”> to item 2 of line 1 of field “MyField”
>
> How do I script the stuff inside the <> ? Sometimes that item will be a field, graphic, etc.
>


Hi, Peter.  You could just replace your delimiters:

set the width of (item 1 of line 1 of field “MyField”) to item 2 of line 1 of field “MyField”

— Dick
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Sri
The parenthesis placements are key in such references as they change the order of command processing.

For example:
1. Create a button "Test1" of width 82 (say)
2. Create a field "Field1" of width 168 (say) containing the text: button "Test1"
3. Type into message box
put the width of field "Field1"
Answer: 168
4. Type into message box
put the width of (field "Field1")
Answer: 82

Regards,
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Wprothero
Sri
It may be bad practice to use the word "field" in the name of a field. However, i suspect there's more to it.😏
Bill

William Prothero
http://ed.earthednet.org

> On Jul 25, 2015, at 8:22 AM, Sri <[hidden email]> wrote:
>
> The parenthesis placements are key in such references as they change the
> order of command processing.
>
> For example:
> 1. Create a button "Test1" of width 82 (say)
> 2. Create a field "Field1" of width 168 (say) containing the text: /button
> "Test1"/
> 3. Type into message box
> put the width of field "Field1"
> Answer: 168
> 4. Type into message box
> put the width of (field "Field1")
> Answer: 82
>
> Regards,
> Sri
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Referencing-a-control-name-tp4694325p4694334.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Http://es.earthednet.org
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Thierry Douez
In reply to this post by Sri
Hi Sri,

Try this:

on mouseUp
   put the width of field "Field1"
   put the width of (field "Field1")
end mouseUp

but put this script in a button, not the message box!

This should give you the trick.

HTH,

Thierry

------------------------------------------------
Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage


2015-07-25 16:22 GMT+02:00 Sri <[hidden email]>:

> The parenthesis placements are key in such references as they change the
> order of command processing.
>
> For example:
> 1. Create a button "Test1" of width 82 (say)
> 2. Create a field "Field1" of width 168 (say) containing the text: /button
> "Test1"/
> 3. Type into message box
> put the width of field "Field1"
> Answer: 168
> 4. Type into message box
> put the width of (field "Field1")
> Answer: 82
>
> Regards,
> Sri
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Referencing-a-control-name-tp4694325p4694334.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Sri
This post was updated on .
Hi Thierry:
It does exactly the same as my example - whether you put it in a button or from the message box. It refers to the field object without the parenthesis, and to the button object with parenthesis. This is due to the fact that the parenthesis is evaluated before the rest, as I had hinted.

Am I missing something?

Sri.
Thierry Douez wrote
Hi Sri,

Try this:

on mouseUp
   put the width of field "Field1"
   put the width of (field "Field1")
end mouseUp

but put this script in a button, not the message box!

This should give you the trick.

HTH,

Thierry
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Sri
In reply to this post by Wprothero
Wprothero wrote
Sri
It may be bad practice to use the word "field" in the name of a field. However, i suspect there's more to it.😏
Hi Bill:

This is just a quick example I contrived to prove a point.
I never use "field" for a field's name; I give (very) descriptive names to my objects!

Regards,
Sri.
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

J. Landman Gay
In reply to this post by Sri
On 7/25/2015 9:22 AM, Sri wrote:

> The parenthesis placements are key in such references as they change the
> order of command processing.
>
> For example:
> 1. Create a button "Test1" of width 82 (say)
> 2. Create a field "Field1" of width 168 (say) containing the text: /button
> "Test1"/
> 3. Type into message box
> put the width of field "Field1"
> Answer: 168
> 4. Type into message box
> put the width of (field "Field1")
> Answer: 82

This is working as expected. When you "get" a field, it is the same as
getting the text of the field. In this case, the text is a reference to
a button and because of the parentheses, the engine resolves that as a
reference to the button control.

It is equivalent to:

get the text of fld "Field1" --> "button "test1"
put the width of it --> 82

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Referencing a control name

Peter Bogdanoff
Thank you to all that replied to my question--my learned and esteemed colleagues!

I got an education, and got the job done!

Thanks again,

Peter Bogdanoff
UCLA

On Jul 25, 2015, at 11:49 AM, J. Landman Gay <[hidden email]> wrote:

> On 7/25/2015 9:22 AM, Sri wrote:
>> The parenthesis placements are key in such references as they change the
>> order of command processing.
>>
>> For example:
>> 1. Create a button "Test1" of width 82 (say)
>> 2. Create a field "Field1" of width 168 (say) containing the text: /button
>> "Test1"/
>> 3. Type into message box
>> put the width of field "Field1"
>> Answer: 168
>> 4. Type into message box
>> put the width of (field "Field1")
>> Answer: 82
>
> This is working as expected. When you "get" a field, it is the same as getting the text of the field. In this case, the text is a reference to a button and because of the parentheses, the engine resolves that as a reference to the button control.
>
> It is equivalent to:
>
> get the text of fld "Field1" --> "button "test1"
> put the width of it --> 82
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode