This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-30 17:26:10

rpglurker
New Scratcher
Registered: 2013-01-17
Posts: 24

run-time type binding

I am having issues with run-time method validation.  Here is an example:

script variables (a)
set [a] to (object[sprite1])
run([test] of [sprite1])
(hopefully my scratch code will show up properly)
Note: This is a contrived exampleto demonstrate my point...

If I try to replace sprite1 with variable "a" the "[method] of [object]" block does not recognize the variable "a" as an object of that type and wipes out the reference to the method. like so:

script variables (a)
set [a] to (object[sprite1])
run([    ] of [sprite1])
If I use the "tell [object]" block it creates duplicate copies of any methods I insert into the C-part but actaully seems to run the correct method anyway (as long as you do not try to delete the local duplicate.)

Is there a proper way to get around this?

Thanks...

Offline

 

#2 2013-01-30 17:37:12

dr3w8
Scratcher
Registered: 2011-07-29
Posts: 81

Re: run-time type binding

That isn't Scratch code, you must be using a mod.


http://i46.tinypic.com/1zfr32r.gif
http://i37.tinypic.com/2qixx6c.png

Offline

 

#3 2013-01-30 17:42:46

rpglurker
New Scratcher
Registered: 2013-01-17
Posts: 24

Re: run-time type binding

I am using byob, and the failure is in my ability to draw the proper block types  smile

Offline

 

#4 2013-01-30 18:21:11

rpglurker
New Scratcher
Registered: 2013-01-17
Posts: 24

Re: run-time type binding

ok... a little cleaner

when gf clicked
script variables (a)
set (a v) to <object [sprite1 v]>
run ((test v) of (sprite1 v))
This is BYOB code...

I am just looking for advice on how to avoid issues that will work fine at run-time but are not resolved when being coded...

Offline

 

#5 2013-01-30 18:25:40

rpglurker
New Scratcher
Registered: 2013-01-17
Posts: 24

Re: run-time type binding

This is what happens when I try to substitute a variable for the object

when gf clicked
script variables (a)
set (a v) to <object [sprite1 v]>
run ((         v) of (a))

Offline

 

#6 2013-01-30 18:56:53

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: run-time type binding

You might have more luck with this on Advanced Topics here


http://i50.tinypic.com/ded8m.png

Offline

 

#7 2013-01-30 19:12:31

rpglurker
New Scratcher
Registered: 2013-01-17
Posts: 24

Re: run-time type binding

will do...thank you

Offline

 

Board footer