Computer Science Canada Salary Finder (Regarding records) |
| Author: | xXInsanityXx [ Sun Nov 27, 2005 8:32 am ] | ||||
| Post subject: | Salary Finder (Regarding records) | ||||
Not really a salary finder but thats what i will call this program K, i work at McDonalds, and i want to keep an account of my salary, etc.I decided to create a mini database in turing, and am using records but for some reason my code is not working, im totaly new to records so please bare along...
i have even tried arrays
so could anyone explain why this code is not working? |
|||||
| Author: | Cervantes [ Sun Nov 27, 2005 9:35 am ] | ||
| Post subject: | |||
You can't just get or put an entire record. It would be nice if you could, but you can't. (Actually, you can, but then you're using read/write, and you are not working with the user/the output window: you're working with files. Still, you will likely want to look into that for your program. Check the Turing Walkthrough.) You have to manually get each field of your record.
And I don't know why you had your get in a loop. ![]() |
|||
| Author: | xXInsanityXx [ Sun Nov 27, 2005 10:48 am ] |
| Post subject: | |
Oh, i probably misread, i read a tutorial on records (AsianSensations i think) and it had the record type as an array, so i tried it but i fared no luck... i was wondering if i could get numHours, payPerHour, breakMinutes and write it into a txt document? |
|
| Author: | Cervantes [ Sun Nov 27, 2005 11:41 am ] | ||||
| Post subject: | |||||
xXInsanityXx wrote: Oh, i probably misread, i read a tutorial on records (AsianSensations i think) and it had the record type as an array, so i tried it but i fared no luck...
I'm not sure I understand what you're saying. You did it correctly, in your first post. You just didn't get it correctly. Like I said, you have to get and put each field of the record manually. You can't get and put an entire record at once. (A field of a record is, for example, numHours or salaryWithTax.) xXInsanityXx wrote: i was wondering if i could get numHours, payPerHour, breakMinutes and write it into a txt document?
Sure. There are two ways to do this. First, use put. But like I said, you have to put each field manually.
Alternatively, you could use random-access, via write, which allows you to write a whole record at once (and you can read a whole record at once as well!). Note that you're data file will not be understandable.
|
|||||
| Author: | MysticVegeta [ Sun Nov 27, 2005 11:46 am ] | ||||
| Post subject: | Re: Salary Finder (Regarding records) | ||||
xXInsanityXx wrote: Not really a salary finder but thats what i will call this program
K, i work at McDonalds, and i want to keep an account of my salary, etc.I decided to create a mini database in turing, and am using records but for some reason my code is not working, im totaly new to records so please bare along...
i have even tried arrays
so could anyone explain why this code is not working? I am confused, why do you need records to do it? How about making a program that takes this stuff in using variables and saves it in a text file in a nice clean table... I dont see a use for records but I might be wrong because I dont know what you have planned. |
|||||
| Author: | Cervantes [ Sun Nov 27, 2005 1:10 pm ] |
| Post subject: | Re: Salary Finder (Regarding records) |
MysticVegeta wrote: I am confused, why do you need records to do it? How about making a program that takes this stuff in using variables and saves it in a text file in a nice clean table... I dont see a use for records but I might be wrong because I dont know what you have planned.
Records aren't a bad idea. Especially since they'll allow him to read/write things to files very easily. |
|
| Author: | MysticVegeta [ Sun Nov 27, 2005 2:03 pm ] |
| Post subject: | |
Me thinks using varibles should be able to do that, if you put them in a loop that is. |
|
| Author: | Cervantes [ Sun Nov 27, 2005 2:08 pm ] |
| Post subject: | |
MysticVegeta wrote: Me thinks using varibles should be able to do that, if you put them in a loop that is.
Absolutely. But which is neater? Do you want to package all the data regarding his pay into a single variable unit? Or would you prefer to leave it floating around, like ... like the potato chips that Homer brought about the spacecraft. Sorry, I couldn't think of a better simile. |
|
| Author: | wtd [ Sun Nov 27, 2005 2:44 pm ] |
| Post subject: | |
You want barbeque chips, and your friend wants ranch chips. You can either have have a big barrel full of assorted chips and sort them out, or you can have two sealed bags that you know only contain either barbeque or ranch chips. |
|