Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Having Quotations in Data Commands + Arithmetic/Variables If Not
- Nambaseking01
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
Hello everyone!
Once again, I need help with Proli. So now there are data commands like output() and assign_var() -but they don't have double quotations in them. So, when a user tries to print something (or do whatever with data commands) it has to be with parentheses and then quotations, no matter what type. But if there are no quotations then the system has to check whether the value has a formula or a number or a variable. For example, these types but then with all data commands:
output(1)
output(1 + 2)
output(var1)
output(var1 + var2)
And they have to be able to take infinite parameters. But if it's not one of these cases, then it has to be like this:
output(“Hi!”)
If there are arithmetic values instead of quotations then the system will just combine the two and not work. For example:
output(1 + 2) - will output 3
output (var1 + var2) - will increment both values
output(“1 + 2”) - will output 1 + 2
output(“var1 + var2”) - will output var1 + var2
But there's another special thing with this. It has to take all math symbols (++, –, /, *, +, -,) and also, there can be a plus sign between two strings to combine the two like this:
output(“1 + 2”) - will output 1 + 2
output(“1” + “2”) - will output 12
If there are any mistakes in the syntax, it has to print out an error. Thank you so much for helping!
Remember, this needs to work with all commands accepting data!
~Nammy~
Once again, I need help with Proli. So now there are data commands like output() and assign_var() -but they don't have double quotations in them. So, when a user tries to print something (or do whatever with data commands) it has to be with parentheses and then quotations, no matter what type. But if there are no quotations then the system has to check whether the value has a formula or a number or a variable. For example, these types but then with all data commands:
output(1)
output(1 + 2)
output(var1)
output(var1 + var2)
And they have to be able to take infinite parameters. But if it's not one of these cases, then it has to be like this:
output(“Hi!”)
If there are arithmetic values instead of quotations then the system will just combine the two and not work. For example:
output(1 + 2) - will output 3
output (var1 + var2) - will increment both values
output(“1 + 2”) - will output 1 + 2
output(“var1 + var2”) - will output var1 + var2
But there's another special thing with this. It has to take all math symbols (++, –, /, *, +, -,) and also, there can be a plus sign between two strings to combine the two like this:
output(“1 + 2”) - will output 1 + 2
output(“1” + “2”) - will output 12
If there are any mistakes in the syntax, it has to print out an error. Thank you so much for helping!
Remember, this needs to work with all commands accepting data!
~Nammy~
Last edited by Nambaseking01 (Dec. 21, 2019 16:55:13)
Hey there! My name is Nammy. I'm a male Forum Helper and Scratch Wiki Editor.
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
- ContourLines
- Scratcher
500+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
For the infinite parameter thing look inside parallel
idk anymore
- Nambaseking01
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
For the infinite parameter thing look inside parallel
But there is more to it.
Hey there! My name is Nammy. I'm a male Forum Helper and Scratch Wiki Editor.
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
- Nambaseking01
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
Bump
Hey there! My name is Nammy. I'm a male Forum Helper and Scratch Wiki Editor.
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
- deck26
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
Doesn't sound difficult. You check the parameters character by character.
First non-space character decides what mode you're in.
If not a quote any subsequent quote makes the input invalid. Otherwise you know you're in ‘calculation’ mode. There are lots of calculator projects in Scratch,
If it is a quote mark then you're in text mode and will only accept data between quotes or a plus sign between data in quotes. You decide whether a plus with nothing following it is invalid. Easy to then just put all characters between quotes in a list.
First non-space character decides what mode you're in.
If not a quote any subsequent quote makes the input invalid. Otherwise you know you're in ‘calculation’ mode. There are lots of calculator projects in Scratch,
If it is a quote mark then you're in text mode and will only accept data between quotes or a plus sign between data in quotes. You decide whether a plus with nothing following it is invalid. Easy to then just put all characters between quotes in a list.
- Nambaseking01
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
Doesn't sound difficult. You check the parameters character by character.
First non-space character decides what mode you're in.
If not a quote any subsequent quote makes the input invalid. Otherwise you know you're in ‘calculation’ mode. There are lots of calculator projects in Scratch,
If it is a quote mark then you're in text mode and will only accept data between quotes or a plus sign between data in quotes. You decide whether a plus with nothing following it is invalid. Easy to then just put all characters between quotes in a list.
I find it hard to convert your ideas into code…
Hey there! My name is Nammy. I'm a male Forum Helper and Scratch Wiki Editor.
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
- deck26
- Scratcher
1000+ posts
Having Quotations in Data Commands + Arithmetic/Variables If Not
Coding is the easy part!Doesn't sound difficult. You check the parameters character by character.
First non-space character decides what mode you're in.
If not a quote any subsequent quote makes the input invalid. Otherwise you know you're in ‘calculation’ mode. There are lots of calculator projects in Scratch,
If it is a quote mark then you're in text mode and will only accept data between quotes or a plus sign between data in quotes. You decide whether a plus with nothing following it is invalid. Easy to then just put all characters between quotes in a list.
I find it hard to convert your ideas into code…
Repeat loop
check character until not space
end loop
if quote set mode to text else set to data
text mode
set variable to blank and then repeat as required
repeat until end of input or next char is quote - append next char to variable, move to next char - reject if get to end of input
(presumably next input should be plus)
repeat checking next char is space or plus - reject input if not unless hit end of input
repeat checking next char is space or quote - reject if not or if input ends
end of text mode
data mode - look at calculator projects
- Discussion Forums
- » Help with Scripts
- » Having Quotations in Data Commands + Arithmetic/Variables If Not