I have a script and would like it changed into a block, anyone who can do it here it is:
Last edited by johnnydean1 (2010-08-09 05:37:35)
Offline
what's this for? i'd be happy to help (it's not hard at all anyway) but the code seems a bit long, i might be able to shorten it if you can tell me what it's for
Offline
Well Ive just improved, its for mesh list sharing.
Offline
Sorry a new version!
Offline
List1 and List2 are examples of lists
Offline
Another update, using Panther blocks.
Offline
Code for the
get $String$ from mesh
reporter
| t11 t12 t13 t14 input output|
input_ t1.
t11 _ #('slider' 'light' 'sound' 'resistance' ).
t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
(t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
ifNotNil:
[t13 _ t12 scratchServer sensorNames.
t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].
^ output.
This reports 0 not error! so, thats why!
Last edited by johnnydean1 (2010-08-09 05:52:50)
Offline
me still no understand
so did you solve your problem?
Offline
What problem, can you just turn the script into a block.
Offline
basically, yes. i don't know how. But the information of you script can be transferred into the Browser to create a block. Sadly, uploading this will destroy the block, and it will nott work. SO I suggest not making a block.
Offline
Ahh your not getting me, I want to make this script into a block to use in a change set. I do know squeak and could make it myself if I wanted to.
Offline
I attempted but its not working. I missed out the last bit:
| t2 t3 t4 t5 t6 t7 t8 t9 t10 repeat t11 t12 t13 t14 input output quote trues temp deafult |
deafult_ 'No list'.
quote_ #('').
quote_ self letter: (3) of: (quote).
repeat_ 50.
t10_ deafult.
t6_ 0.
t5_ 0.
t4_ ''.
t7_ 0.
repeat timesRepeat: [
t5_ t5 + 1.
t3_ self concatenate: ('List') with: (t5).
input_ t3.
t11 _ #('slider' 'light' 'sound' 'resistance' ).
t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
(t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
ifNotNil:
[t13 _ t12 scratchServer sensorNames.
t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].
t2_ output.
t2 = 0
ifTrue: [
t2_ self varNamesMenu.
t11_ self concatenate: (quote) with: (t3).
t11_ self concatenate: (t11) with: (quote).
t2_ self indexOf: (t11) startingAt: (0) in: (t2).
t2 = 0
ifFalse: [
t2_ self reportVar: (t3).
].
].
t2 = 0
ifFalse: [
t4_ self concatenate: (t4) with: ('/').
t4_ self concatenate: (t4) with: (t5).
t7_ t7 + 1.
].
].
t2_ 0.
t8_ t4.
repeat_ 100.
t7 timesRepeat: [
t2_ t2 + 1.
t3_ 0.
t4_ 0.
trues_ false.
repeat timesRepeat: [
trues = false
ifTrue: [
t4_ t4 + 1.
t5_ self letter: (t4) of: (t8).
t5 = '/'
ifTrue: [
t3_ t3 + 1.
].
t3 = t2
ifTrue: [
trues_ true.
].
].
].
t6_ ''.
t4_ t4 + 1.
trues_ false.
repeat timesRepeat: [
trues = false
ifTrue:
[
t5_ self letter: (t4) of: (t8).
t6_ self concatenate: (t6) with: (t5).
t4_ t4 + 1.
temp_ self stringLength: (t8).
t4 > temp
ifTrue: [
trues_ true.
].
temp_ self letter: (t4) of: (t8).
temp = '/'
ifTrue: [
trues_ true.
].
].
].
t11_ self concatenate: ('List') with: (t6).
input_ t11.
t11 _ #('slider' 'light' 'sound' 'resistance' ).
t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
(t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
ifNotNil:
[t13 _ t12 scratchServer sensorNames.
t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].
t3_ output.
t3 = 0
ifTrue: [
t3_ self reportVar: (t11).
].
t4_ 1.
t7_ 0.
t9_ ''.
trues_ false.
repeat timesRepeat: [
trues = false
ifTrue: [
t4_ t4 + 1.
t5_ self letter: (t4) of: (t3).
t5 = '/'
ifTrue: [
t7_ t7 + 1.
]
ifFalse: [
t9_ self concatenate: (t9) with: (t5).
].
temp_ self stringLength: (t3).
t4 > temp
ifTrue: [
trues_ true.
].
t7 = 1
ifTrue: [
trues_ true.
].
].
].
t9 = t1
ifTrue: [
t10_ t3.
].
].
^ t10
Offline
^ I did that in Panther BTW!
Offline
*puzzled* im not getting this. no help srry
Offline
Can you convert everything after the
wait 0 secs
into a single block.
What it does
You enter a string
%s = hi
(Its t1)
it then sets a index variable to 0
it then checks 50 times by changing the index by 1
it then does (join (List) and (index) ) so it gets:
List1
List2
List3
...
It then sees if it exists over mesh, if not (=0) then it sees if it has it.
Then if it does, it records the index number.
It then checks the index numbers lists that its recorded e.g
List1 = /hi/item1/
List2 = /list2/item1/item2/
So as we entered hi it reports
/item1/
Get it, it searches the variables for your chosen list!
Offline
Well NXIII can you do it?
Offline