Okay so I am making a programming language in Scratch. I need to know how i could split a string. For instance, if someone wanted to print text they could write:
SAY "Hello"
If possible, I would like it to just print Hello to the Output list. Is this possible?
Offline
ProgrammingFreak wrote:
Okay so I am making a programming language in Scratch. I need to know how i could split a string. For instance, if someone wanted to print text they could write:
Code:
SAY "Hello"If possible, I would like it to just print Hello to the Output list. Is this possible?
Yes, it just requires a lot of repeats, if elses, joins, letter (), and length ofs. When I gave it a try, I used a symbol (e.g. /s) to signify that the command was a say command. I would post an example, but I'm a bit busy search my hard drive for some sprites I've lost.
Offline
markyparky56 wrote:
ProgrammingFreak wrote:
Okay so I am making a programming language in Scratch. I need to know how i could split a string. For instance, if someone wanted to print text they could write:
Code:
SAY "Hello"If possible, I would like it to just print Hello to the Output list. Is this possible?
Yes, it just requires a lot of repeats, if elses, joins, letter (), and length ofs. When I gave it a try, I used a symbol (e.g. /s) to signify that the command was a say command. I would post an example, but I'm a bit busy search my hard drive for some sprites I've lost.
![]()
OKay, so like:
/s 'hello'
Offline
ProgrammingFreak wrote:
markyparky56 wrote:
ProgrammingFreak wrote:
Okay so I am making a programming language in Scratch. I need to know how i could split a string. For instance, if someone wanted to print text they could write:
Code:
SAY "Hello"If possible, I would like it to just print Hello to the Output list. Is this possible?
Yes, it just requires a lot of repeats, if elses, joins, letter (), and length ofs. When I gave it a try, I used a symbol (e.g. /s) to signify that the command was a say command. I would post an example, but I'm a bit busy search my hard drive for some sprites I've lost.
![]()
OKay, so like:
Code:
/s 'hello'
You don't even really have to put the speech marks, unless you add compatibility with variables, and stuff.
Offline
Look at my latest project it does just this!
EDIT:
Link here
Last edited by johnnydean1 (2011-04-18 16:00:39)
Offline
johnnydean1 wrote:
Look at my latest project it does just this!
EDIT:
Link here
Cool!
Offline
johnnydean1 wrote:
Need anything else?
Would you like to help work on it?
Offline
ProgrammingFreak wrote:
johnnydean1 wrote:
Need anything else?
Would you like to help work on it?
![]()
I can help. You can post on that project with anything you need.
Offline
johnnydean1 wrote:
ProgrammingFreak wrote:
johnnydean1 wrote:
Need anything else?
Would you like to help work on it?
![]()
I can help. You can post on that project with anything you need.
Okay. Lemme upload a new version that I can add a few things and then we can talk.
Offline
Um, I'd like to use your code. Is that all right? Well at least guide me to the part of the splitting part. Should I just copy all your code into mine? Or put what I have onto yours?
the first will take forever....
Offline
johnnydean1 wrote:
You can copy anything you want
![]()
Okay.
*starts the long copying process*
I wish scratch had a better way.
Last edited by ProgrammingFreak (2011-04-18 16:34:06)
Offline
ProgrammingFreak wrote:
johnnydean1 wrote:
You can copy anything you want
![]()
Okay.
![]()
*starts the long copying process*
I wish scratch had a better way.![]()
Same
Offline
ProgrammingFreak wrote:
johnnydean1 wrote:
You can copy anything you want
![]()
Okay.
![]()
*starts the long copying process*
I wish scratch had a better way.![]()
Ever heard of export? You can copy what parts you want into a sprite, export it and import it into your own project.
Offline
markyparky56 wrote:
ProgrammingFreak wrote:
johnnydean1 wrote:
You can copy anything you want
![]()
Okay.
![]()
*starts the long copying process*
I wish scratch had a better way.![]()
Ever heard of export? You can copy what parts you want into a sprite, export it and import it into your own project.
OH lol. I've never used it for the code before.
Offline
ProgrammingFreak wrote:
markyparky56 wrote:
ProgrammingFreak wrote:
Okay.![]()
*starts the long copying process*
I wish scratch had a better way.![]()
Ever heard of export? You can copy what parts you want into a sprite, export it and import it into your own project.
OH lol. I've never used it for the code before.
![]()
From what I can see, all the code for JD1's project is in one sprite, so all you need to do it export said sprite. It is, in essence, an interpreter at the simplest. Nice work Jd1.
Though, I've noticed that in the Experimental viewer, it doesn't loop like in the player.
Offline
markyparky56 wrote:
Nice work Jd1.
Though, I've noticed that in the Experimental viewer, it doesn't loop like in the player.
Why thank you.
And the experimental viewer must be a bug...
Offline
johnnydean1 wrote:
markyparky56 wrote:
Nice work Jd1.
Though, I've noticed that in the Experimental viewer, it doesn't loop like in the player.
Why thank you.
And the experimental viewer must be a bug...
It is afterall, experimental.
Offline
markyparky56 wrote:
johnnydean1 wrote:
markyparky56 wrote:
Nice work Jd1.
Though, I've noticed that in the Experimental viewer, it doesn't loop like in the player.
Why thank you.
And the experimental viewer must be a bug...It is afterall, experimental.
Well yes...
@Everyone
I am working on a new way of doing this. I don't think it will be faster but it should be better at detecting and able to use spaces.
EDIT:
Done see my latest project. It doesn't work in flash player (v23) as <0= > (0=nothing).
Last edited by johnnydean1 (2011-04-19 03:30:30)
Offline
try this idea:
I had to do the same thing so I came up with this idea. the cmd is original, cmdname would be the SAY bit and cmdargs would be the 'Hello World' bit.
--EDIT--
where the bit says nothing or nothing one of them is a space and the other nothing.
Last edited by logiblocs (2011-04-19 10:50:48)
Offline
Splitting strings for a programming language gets annoying after a while. I usually have a script load all the characters into a list, then loop through the list until it finds the character to split at, then load both or all strings into variables or a list.
Offline
You could use the method I use in QuickSilver.
Offline
Why again?
You can use a command entrance char (i use <) and a command exit char (>) and use the arguments in a list like:
<say> hello; 2
would say hello for 2 secs.
Offline
That sounds like a good idea, bbbeb.
Offline