Script for setting the script of a object

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
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Script for setting the script of a object

Post by montymay » Sat Nov 29, 2014 9:17 am

Maybe I'm overlooking something obvious, but the following script does not seem to do anything:

Code: Select all

on mouseup
set the script of grc GRAPHIC_NAME_A to the script of grc GRAPHIC_NAME_B 
end mouseup
GRAPHIC_NAME_A and GRAPHIC_NAME_B are either the actual names of the objects, in quotation marks, or are variables that contain the actual names. When I open the script for the second object after running both versions of the script, the script of the second object is empty. Thank you for any suggestions.

Monty

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Script for setting the script of a object

Post by Dixie » Sat Nov 29, 2014 9:27 am

I have just done more or less the same to test... 2 graphics, then in the script of a button :-

Code: Select all

on mouseUp
   set the script of grc 2 to the script of grc 1
end mouseUp
This works for me...

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Script for setting the script of a object

Post by montymay » Sat Nov 29, 2014 10:04 am

Thanks, Dixie. Your script is in the same form as mine, and both our scripts track the example for the command in the Dictionary. I even created graphics named 1 & 2 and used your script verbatim, but the script of grc 2 remains empty. I'll keep trying but welcome other suggestions.

Monty

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Script for setting the script of a object

Post by SparkOut » Sat Nov 29, 2014 10:13 am

I have heard someone mention similar a long time ago, and it turned out the script was there but just not visible in the editor, due to some rendering problem. (Maybe linked to the reason why copy/pasting code from other sources eg web page doesn't work???)
Saving the stack, closing lc and opening again showed the script in place. Worth a try?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Script for setting the script of a object

Post by jmburnod » Sat Nov 29, 2014 11:03 am

Hi All,
Strange
Dixie's script works for me with LC 5.5,6.7,7, and community 6.1
Best regards
Jean-Marc
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Script for setting the script of a object

Post by jacque » Sat Nov 29, 2014 4:38 pm

Do you have more than one graphic with the same name? The script may be setting a different one than you expect.

Also, iuf the graphics have numbers for names without any alpha characters then the engine is very likely to choose the graphic with that layer number rather than the one with the numeric name. Never name objects with numerals only, always include at least one alpha character.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Script for setting the script of a object

Post by FourthWorld » Sat Nov 29, 2014 4:40 pm

SparkOut wrote:copy/pasting code from other sources eg web page doesn't work
UTR - Recipe?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply