work with the numbers

Just starting out? Need help? Post your questions and find answers here.
Thorn
New User
New User
Posts: 6
Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)

work with the numbers

Post 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
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post 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.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Thorn
New User
New User
Posts: 6
Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)

Post by Thorn »

I find the Val() command in my Basic' book some minutes ago :P
Anyway thanks a lot for the answer.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

follow the link below...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
jb
User
User
Posts: 37
Joined: Wed Jul 14, 2004 11:58 pm
Location: United States

Post 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?
-jb
Post Reply