I think that there should be a block that makes a new variable. That way, if you're, say, making a flashcard project, you'd be able to have as many as you want!
Offline
And... how would it be used? I mean, you have to say the variable name, but, if it doesn't really exist until it's ran... well, you should understand. Plus, it would be hard to code in Squeak. And what if someone put this in a "forever" block? Lagging to the max.
Offline
That can be done in Panther, but I agree it would be useful to have. Though as PaperMario123 said, it would cause extreme lag over time.
Offline
PaperMario123 wrote:
And... how would it be used? Well, it could be used to create a new document in a word processor, or it could be used to make flashcards or something. I mean, you have to say the variable name, but, if it doesn't really exist until it's ran... well, you should understand. You would be able to do this in the editor. You would right click on the variable block and it would say "name my copies...". There would be another variable created called "variable1 copies", which would allow you to program the copies. Plus, it would be hard to code in Squeak. I don't know enough about Squeak to give some workaround, but I'll take your word for it . And what if someone put this in a "forever" block? Lagging to the max. I agree, it would cause lagging, but no project should need an infinite number of variables.
Last edited by WingsGames (2011-12-19 14:13:16)
Offline
WingsGames wrote:
PaperMario123 wrote:
And... how would it be used? Well, it could be used to create a new document in a word processor, or it could be used to make flashcards or something. I mean, you have to say the variable name, but, if it doesn't really exist until it's ran... well, you should understand. You would be able to do this in the editor. You would right click on the variable block and it would say "name my copies...". There would be another variable created called "variable1 copies", which would allow you to program the copies. Plus, it would be hard to code in Squeak. I don't know enough about Squeak to give some workaround, but I'll take your word for it . And what if someone put this in a "forever" block? Lagging to the max. I agree, it would cause lagging, but no project should need an infinite number of variables.
Also, if you were using a SmartPort system for mesh chat boxes ( a variable is created for each ip to transfer data [for my Panther projects]), you would want to be able to create/delete variables. Maybe also a create list and delete list blocks.
Hehehe. As for the squeak code, just ask the Panther devs.
Last edited by SJRCS_011 (2011-12-20 17:35:46)
Offline
If it was put in a c-block, it will automaticly be deleted at the end of the c-block so if put in a forever block it will be constantly be created and deleted. There would also be blocks (variable named [ ]) and |set variable named [ ] to [ ]| so you can use theese variables. It is possible in squeak, it works in panther.
Offline
joefarebrother wrote:
If it was put in a c-block, it will automaticly be deleted at the end of the c-block so if put in a forever block it will be constantly be created and deleted. There would also be blocks (variable named [ ]) and |set variable named [ ] to [ ]| so you can use theese variables. It is possible in squeak, it works in panther.
So, that solves the lagging problem.
Offline
bump
Offline
prokohtu wrote:
but you can also use a list for that
How so?
Offline
WingsGames wrote:
prokohtu wrote:
but you can also use a list for that
How so?
add _ to _
Basically, just using the list items as variables.
However, you wouldn't be able to use this for mesh.
Offline
if you just do this it would work[blocks] http://scratch.mit.edu/forums/viewtopic.php?id=84017#req_message
http://scratch.mit.edu/forums/viewtopic.php?id=84017#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=84017#req_message
http://scratch.mit.edu/forums/viewtopic.php?id=84017#req_message
[/blocks]
Offline
what you could do to solve the lag is, to have sqeuck do a counter (ctr) variable that counts how many times a variable is made using the block, and once more than ___ amount is made it stops and highlights the block red, like if you were to do:
when gf forever if <(0 / 0)> end
Offline
MountainBoy wrote:
what you could do to solve the lag is, to have sqeuck do a counter (ctr) variable that counts how many times a variable is made using the block, and once more than ___ amount is made it stops and highlights the block red, like if you were to do:
when gf clicked <forever if <(0 / 0)> end
Last edited by soniku3 (2012-08-12 02:48:24)
Offline
MountainBoy wrote:
what you could do to solve the lag is, to have sqeuck do a counter (ctr) variable that counts how many times a variable is made using the block, and once more than ___ amount is made it stops and highlights the block red, like if you were to do:
when gf forever if <(0 / 0)> end
Necropost...
Besides, you can use lists
Offline
Support. This isn't a necropost, as I was going to suggest it, but I searched.
Lists won't work, as you would need to know exactly what position in the list each "variable" were in.
Offline
One list called vars and another called vals.
when i receive [setvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> replace item (index) of [vals v] with (value) stop script end end add (variable) to [vars v] add (value) to [vals v] when i receive [getvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> set [value v] to (item (index) of [vals v]) stop script end end add (variable) to [vars v] add [0] to [vals v] //or any default value set [value v] to [0]And that's how you work around it with lists
Offline
joefarebrother wrote:
One list called vars and another called vals.
when i receive [setvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> replace item (index) of [vals v] with (value) stop script end end add (variable) to [vars v] add (value) to [vals v] when i receive [getvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> set [value v] to (item (index) of [vals v]) stop script end end add (variable) to [vars v] add [0] to [vals v] //or any default value set [value v] to [0]And that's how you work around it with lists
How many Scratchers know how to use that? How many people use lists? What if you need to make a variable but later replace it?
Offline
firedrake969_test wrote:
joefarebrother wrote:
One list called vars and another called vals.
when i receive [setvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> replace item (index) of [vals v] with (value) stop script end end add (variable) to [vars v] add (value) to [vals v] when i receive [getvar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> set [value v] to (item (index) of [vals v]) stop script end end add (variable) to [vars v] add [0] to [vals v] //or any default value set [value v] to [0]And that's how you work around it with listsHow many Scratchers know how to use that? How many people use lists? What if you need to make a variable but later replace it?
You would just iterate through the "var" list, finding the name, and then use whatever item # it's at to replace the value in the "val" list to whatever you want.
when gf clicked set [variable v] to [variable name] set [value v] to [whatever value you want it to change to] broadcast [changevar v] when i receive [changevar v] set [index v] to (0) repeat (length of [vars v]) change [index v] by (1) if <(item (index) of [vars v]) = (variable)> replace item (index) of [vals v] with (value) stop script end end
Offline
I'm not sure if the above script works, but if it does then use it.
The point is that there are a lot of things that you can actually do (even with lists, even if you don't like to use them) with the current blocks (or ones in 2.0) and if you don't go finding these workarounds, you won't be learning as much as you could.
Offline