Page 1 of 1

work with the numbers

Posted: Wed Nov 09, 2005 6:12 pm
by Thorn
Hi
What can i do for work directly with the numbers?

for example:

Code: Select all

number=input()

if number=10
printn ("ten!")
if number=20
printn("twenty")
....
thank

Posted: Wed Nov 09, 2005 6:36 pm
by dagcrack
Well this is... way too basic..

You must either convert the input into a numeric value using Val() or work with the strings directly.. 2 examples:


First one with string converted to numeric value (integer):

Code: Select all

OpenConsole()

Print("Give me a number: ")
Number= Val(Input())
PrintN("")

Select Number
  
  Case 10
    PrintN ("ten!")
    
  Case 20
    PrintN("twenty")
    
  Default
    PrintN("bah")
    
EndSelect

Delay(1000)
End

Second one with string directly:

Code: Select all

OpenConsole()

Print("Give me a number: ")
Number.s = Input()
PrintN("")

Select Number
  
  Case "10"
    PrintN ("ten!")
    
  Case "20"
    PrintN("twenty")
    
  Default
    PrintN("bah")
    
EndSelect

Delay(1000)
End

I suggest you reading the manual and perhaps some BASIC and programming books.

Cheers.

Posted: Wed Nov 09, 2005 6:51 pm
by Thorn
I find the Val() command in my Basic' book some minutes ago :P
Anyway thanks a lot for the answer.

Posted: Wed Nov 09, 2005 7:09 pm
by blueznl
follow the link below...

Posted: Wed Nov 09, 2005 7:40 pm
by jb
When I first started working with PureBasic I found blueznl's survival guide to be invaluable. Thanks blueznl!

P.S. Do you have this in PDF format by any chance?