Computer Science Canada error trap help me please |
Author: | XeRoideR999 [ Sun Jan 18, 2004 2:26 pm ] |
Post subject: | error trap help me please |
ok guys, i got a question? how do i error trap my thing, its a converting minutes to hours and minutes. when i type a whole number example: 122 its 2 hours and 2 minutes. and when i type 2.4 or letters, i want it to repeat my question. please help me with this, ijust need the code for it. Quote: procedure percent
(x1, y1, x2, y2, num : int) drawfillbox (x1 - 2, y1 - 2, x2 + 2, y2 + 2, grey) drawbox (x1 - 2, y1 - 2, x2 + 2, y2 + 2, black) for i : 1 .. round ((x2 - x1) * num / 100) by 10 drawfillbox (x1 + i, y1, x1 + i + 7, y2, blue) end for end percent put "Enter a number to be converted into hours and minutes." put "" put "NOTE: please enter a whole number, and not Decimals or Letters!!" put "" put "when you finish the typing press enter" var minutes, minu2, newvar, newvar2 : int get minutes newvar := minutes div 60 newvar2 := minutes mod 60 cls locate (8, 30) color (1) put "Converting..." for i : 1 .. 100 locate (10, 34) put i, "%" percent (100, 100, 500, 110, i) delay (50) end for cls locate (7, 23) put "Your Converted Number is Here" locate (10, 25) put newvar, "Hours and ", newvar2, " Minutes" |
Author: | Tony [ Sun Jan 18, 2004 2:27 pm ] |
Post subject: | |
there's a tutorial on that... you accept input as string then use strintok() and strint() to convert to number |