sandyrepope
15-02-2007, 22:35
If we write small sections of code using the console that we think would be useful to beginners, is this the right place to put them?
Here is an example of what I mean:
Uses "CONSOLE"
'define variables so program knows them
%Menu_Color_Normal = 7
dim Choose_type as string
dim Result as string
DIM Fruit_type as string
'comsole_printat doesn't let the cursor drop down to the next line
'the first CONSOLE_WRITELINE does that. The second CONSOLE_WRITE_LINE
'provides a blank line
console_printat("What do you like better? ",0 ,0, %Menu_Color_Normal)
console_writeline("")
console_writeline("")
console_writeline("Type of fruit?")
console_writeline("(A)pple, (B)anana, or (P)ear")
Choose_type = %false
WHILE Choose_type = %FALSE
'---Read keyboard input
Result = Console_inKeyb
'---Handle returned string
select case Result
case "a","A"
Fruit_Type = "Apple"
Choose_type = %true
case "b","B"
Fruit_Type = "Banana"
Choose_type = %true
case "p","P"
Fruit_type = "Pear"
Choose_type = %TRUE
end select
wend
console_writeline("")
console_writeline("Your choice: " & Fruit_type)
Console_SetCursorPosition(30, 23)
Console_WriteLine("Press any key to exit.")
Console_WaitKey
If this isn't the right place for such please let me know.
Here is an example of what I mean:
Uses "CONSOLE"
'define variables so program knows them
%Menu_Color_Normal = 7
dim Choose_type as string
dim Result as string
DIM Fruit_type as string
'comsole_printat doesn't let the cursor drop down to the next line
'the first CONSOLE_WRITELINE does that. The second CONSOLE_WRITE_LINE
'provides a blank line
console_printat("What do you like better? ",0 ,0, %Menu_Color_Normal)
console_writeline("")
console_writeline("")
console_writeline("Type of fruit?")
console_writeline("(A)pple, (B)anana, or (P)ear")
Choose_type = %false
WHILE Choose_type = %FALSE
'---Read keyboard input
Result = Console_inKeyb
'---Handle returned string
select case Result
case "a","A"
Fruit_Type = "Apple"
Choose_type = %true
case "b","B"
Fruit_Type = "Banana"
Choose_type = %true
case "p","P"
Fruit_type = "Pear"
Choose_type = %TRUE
end select
wend
console_writeline("")
console_writeline("Your choice: " & Fruit_type)
Console_SetCursorPosition(30, 23)
Console_WriteLine("Press any key to exit.")
Console_WaitKey
If this isn't the right place for such please let me know.