Now that that's over...

New to FreeBASIC? Post your questions here.
whitetiger0990
Posts: 92
Joined: May 27, 2005 12:34
Location: Universe, Milky Way, Sol III, North-East Hemisphere, North America, USA, ., Chair
Contact:

Post by whitetiger0990 »

No yuo forgot the quotes. (Also you had random 'then' s after your inputs)
Also you really only need one input for the number not three.
Also you can use Select Case ( http://www.freebasic.net/wiki/wikka.php ... Selectcase )

Your code fixed:

Code: Select all

do
 input "Type bin for binary, hex for hexadecimal or oct for octal: ", 
choice$
 input "Type your number: ", nmbr%
 If choice$ = "bin" then
     print bin$(nmbr%)
 If choice$ = "hex" then
     print hex$(nmbr%)
 If choice$ = "oct" then
     print oct$(nmbrl%)
loop
Select case:

Code: Select all

do
 input "Type bin for binary, hex for hexadecimal or oct for octal: ", choice$
input "Type your number: ", nmbr% 
select case nmbr$
case "bin"
     print bin$(nmbr%)
case "hex" 
     print hex$(nmbr%)
case "oct" 
     print oct$(nmbr%)
end select
loop
and if you really want to push it

Code: Select all

do
 input "Type bin for binary, hex for hexadecimal or oct for octal: ", choice$
input "Type your number: ", nmbr% 
select case nmbr$
case "bin"
     print bin$(nmbr%)
case "hex" 
     print hex$(nmbr%)
case "oct" 
     print oct$(nmbr%)
case else
     print "Invalid selection"
end select
loop
I hope this helps. I may have made it more confuusing =o
Aerthe
Posts: 249
Joined: May 30, 2005 20:44
Location: Here
Contact:

Post by Aerthe »

um...there was a slight error in the code

Code: Select all

do 
 input "Type bin for binary, hex for hexadecimal or oct for octal: ", choice$ 
input "Type your number: ", nmbr% 
select case CHOICE$ 'It's supposed to be choice not nmbr!
case "bin" 
     print bin$(nmbr%) 
case "hex" 
     print hex$(nmbr%) 
case "oct" 
     print oct$(nmbr%) 
case else 
     print "Invalid selection" 
end select 
loop
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Post by dumbledore »

lol, there was a "slight" error in his other code too, you can't do multiline ifs without end ifs! :D did you even test it?
Post Reply