LoginLogin

HELP REQUIRED

Root / Programming Questions / [.]

randoCreated:
so, i am making a scratch like game, petit-basic, but im putting an input, and its not working! help!

heres what i have.
input"X:",X$

Actually, it is working.

no, it saysillegal function call in

Then:
heres what i have.
input"X:",X$
That's not what you have.

yes, it is.

I'm confused? Are you trying to get touchscreen keyboard input or 3ds button input?

wait, idea! just a sec!

IT WORKED! sorry for the wast of time, i just needed to turn of the xscreen. sorry please forgive. me horrible at program if i dont notice that.

So, I was playing around with this, trying to make INPUT return to me an illegal function call error, when I noticed this:
INPUT "ABC"[0],X$
gives a type mismatch error, while
INPUT "ABC"[0];X$
does not. All strings can use Subscripts like arrays, and
"ABC"[0]
should be compacted into its own literal at compile time, right? The manual says this on INPUT: "Only when ; is used, a string variable can be used for the guided text string" The guided text string is "ABC", however, it is not a string variable. Does this mean that when subscripts are used on a string literal, it is no longer a string literal?

"String literal" in programming terminology specifically means writing something like "ABC", rather than any arbitrary string expression.

sorry, but i already found the problem. but i guess this can become a guid for those who forget to turn of xscreen, like me! i can just look here if i need help again. like thats gunna happen.

but thx for the help, those who tried.

INPUT string,variable isn't allowed at all. You have to use a semicolon to separate the text from the variable list.
Not true. Take this from the manual: "If , (comma) is used instead of ; after guiding text string, a ? mark will not be displayed" The discrepancy I'm referring to is that, according to the manual which describes how the INPUT syntax works, "ABC"[0] is treated as a string variable instead of a string literal.

It looks like you can only use plain string literals , and not expressions like "A"*2 or "ABC"[0] And somehow inputting to a CHARACTER is allowed... INPUT Q$[0] Even though this is NOT passed as a reference, which you can test using a function. This is an important lesson on why using weird syntax should be done carefully to avoid ambiguity and bugs.