LoginLogin

I need coding help.

Root / Programming Questions / [.]

16bitcoderCreated:
I need help for with my program. How could I check for strings and make this work? Like it checks if you say print and prints what is past it. My code:
Linput"";K$
(Checks if K$ is print (Like PRINT" HI))
(Then it'll print only the hi)
EXAMPLE WHEN RUN:

>PRINT HI
HI

I'm not sure what you're asking. But i think i get it a little. Youre saying that the user types "PRINT -some piece of text-" and you want only the piece of text to be displayed. alright, well you would need to do something like this
LINPUT"";K$
P=INSTR$(K$,"PRINT"+CHR$(34))
'That will literally search the inside of K$ for "PRINT"" and it returns the position of the word
This would be helpful only if PRINT" were somewhere inside the string But if PRINT" is always at the beginning of K$, then you could just do this
LINPUT"";K$
P=LEN(K$)
K$=RIGHT$(K$,P-LEN("PRINT"+CHR$(34)))
'or you could just write P-6 instead of all that, doesnt really matter its all the same
thats all i got

I'm not sure what you're asking. But i think i get it a little. Youre saying that the user types "PRINT -some piece of text-" and you want only the piece of text to be displayed. alright, well you would need to do something like this
LINPUT"";K$
P=INSTR$(K$,"PRINT"+CHR$(34))
'That will literally search the inside of K$ for "PRINT"" and it returns the position of the word
This would be helpful only if PRINT" were somewhere inside the string But if PRINT" is always at the beginning of K$, then you could just do this
LINPUT"";K$
P=LEN(K$)
K$=RIGHT$(K$,P-LEN("PRINT"+CHR$(34)))
'or you could just write P-6 instead of all that, doesnt really matter its all the same
thats all i got
Thanks!