Computer Science Canada help: inputting fixed # of characters for integers |
Author: | Jas [ Sun Mar 20, 2005 10:19 pm ] |
Post subject: | help: inputting fixed # of characters for integers |
I am doing a big program in turing for school and i need help. How do u make a program so the user inputs a fixed number of characters for integers. For example, you can do this for a string by: var code : string (9) var familyCode : string (2) var productCode : string (4) var supplierCode : string (2) var locationCode : string (1) but if u do this... var code : int (9) var familyCode : int (2) var productCode : int (4) var supplierCode : int (2) var locationCode : int (1) the program crashes. Also, how do u search for a pattern in an integer. If you declard the code variables as integers, and u try to do the following, the program crashes: familyCode := code (1 .. 2) productCode := code (3 .. 6) supplierCode := code (7 .. 8) locationCode := code (9 .. *) How do u search for a pattern if it is an integer? |
Author: | Cervantes [ Sun Mar 20, 2005 10:36 pm ] | ||||
Post subject: | |||||
For the first question:
You could also expand that so that you can use the backspace key. Not too difficult. Second question: use index. index searches a string though, so you first have to convert the int to a string.
|