Author Topic: String == Stringand some more questions...  (Read 2563 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
String == Stringand some more questions...
« on: January 30, 2012, 11:58:13 pm »
How would I do...
If (/*USER INPUT*/) = "Suicide" :Disp "You Died" ???
This has been troublesome to me...
Also is there any more variables I can use instead of just a-z?
Like if I could do...  HOLY->235
or something...
Thanks :D
* hellninjas just realized he hasn't done basic in a while!
I'm glad to be back :D!!
« Last Edit: January 31, 2012, 12:23:29 am by hellninjas »

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Re: String == Stringand some more questions...
« Reply #1 on: January 31, 2012, 12:03:43 am »
This is BASIC correct?
You would do:
Code: [Select]
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: String == Stringand some more questions...
« Reply #2 on: January 31, 2012, 12:08:05 am »
Code: [Select]
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
else :Disp "Incorrect command"

Could this work?
« Last Edit: January 31, 2012, 12:08:14 am by hellninjas »

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Re: String == Stringand some more questions...
« Reply #3 on: January 31, 2012, 12:13:26 am »
Yeah, that should work, sorry for the late reply
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: String == Stringand some more questions...
« Reply #4 on: January 31, 2012, 12:48:18 am »
Code: [Select]
Input "",Str1
If Str1 = "SUICIDE":Disp "You Died"
else :Disp "Incorrect command"

Could this work?
Nope. If you are using an Else, Then you need a Then then an End.

A correct (non optimized) code would be

Code: [Select]
Input "",Str1
If Str1="SUICIDE"
Then
Disp "You Died"
Else
Disp "Incorrect command"
End

And an optimized code would be

Code: [Select]
Input "",Str1
"Incorrect command"
If Str1="SUICIDE":"You Died"
Disp Ans
« Last Edit: January 31, 2012, 12:23:02 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: String == Stringand some more questions...
« Reply #5 on: January 31, 2012, 12:42:54 pm »
And an optimized code would be

Code: [Select]
Input "",Str1
"Incorrect command"
If Str1="SUICIDE":"You Died"
Disp Ans
More optimized!
Code: [Select]
Input "",Str1
"Incorrect command
If Str1="SUICIDE
"You Died
Disp Ans
The strings could be changed to uppercase, but that would change the output.