I need help for my upcoming project.
Please give me a script that decodes
set (letter) (num1),(num2)
into:
(letter)(num1)(num2)
Credit will be given.
Offline
Are you going to actually have letters? 'set A 3,4' ?
If so, use this. Store the 'set A 3,4' or whatever into a variable called string, and make two variables, var1 and var2.
Please note:
In line 2, that's an empty string. In line 4, that's a single space.
set var1 to 1.
set var2 to ''.
repeat (length of (string)) {
if <<(letter (var1) of (string)) = ' '> or <(letter (var1) of (string)) = ','> {
set var2 to (join (var2) (letter (var1) of (string)). }
change var1 by 1. }
At the end, the string 'A34' (for this example) should be stored in var2.
Last edited by Greenatic (2011-11-29 21:29:06)
Offline
Greenatic wrote:
Are you going to actually have letters? 'set A 3,4' ?
If so, use this. Store the 'set A 3,4' or whatever into a variable called string, and make two variables, var1 and var2.
Please note:
In line 2, that's an empty string. In line 4, that's a single space.
set var1 to 1.
set var2 to ''.
repeat (length of (string)) {
if <<(letter (var1) of (string)) = ' '> or <(letter (var1) of (string)) = ','> {
set var2 to (join (var2) (letter (var1) of (string)). }
change var1 by 1. }
At the end, the string 'A34' (for this example) should be stored in var2.
The output must be 3 seperate variables.
Offline
set [string] to (set A12) set [var1] to (letter(5) of (string) ) set [var2] to (letter(6) of (string) ) set [var3] to (letter(7) of (string) )
Offline
MoreGamesNow wrote:
Code:
set [string] to (set A12) set [var1] to (letter(5) of (string) ) set [var2] to (letter(6) of (string) ) set [var3] to (letter(7) of (string) )
No, the numbers can have a different length.
Offline
Oh, my mistake. I've got code to break up a string into array elements by a character:
set [i] to (0) delete (all) of [list] add () to [list] repeat (length of variable) { change [i] by (1) if(letter (i) of (variable) == [,] ) { add () to [list] } else { replace item (last) of [list] with (join ((item (last) of [list]) with (letter (i) of (variable))) } }
With a little tinkering maybe? Sorry, it's late and I can't help more, maybe tomorrow
Offline
set [string] to (set a40,30) set [i] to (5) delete (all) of [list] add () to [list] repeat (length of (string) ) { change [i] by (1) if (letter (i) of (string) = [,]) { add [] to list } else { replace item (last) of [list] with ((join (item (last) of [list]) with (letter (i) of (string) ) ) ) } }
Offline
You're probably using Internet Explorer, which is one of the few (the only?) browser that doesn't support HTML5 canvas. Actually, I've heard that it does support canvas, but it follows a totally different syntax. Anyway, switch to Firefox or another browser, and it should work.
Offline