Qbasicnews.com

Full Version: My Program (calculates pay for job) still wont load/save....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i made this program to calcualte the pay total per day for my work but it still dosnt save and load files correctly. can someone help me with that? well here is the code:

Quote:Screen 13
Cls
Print ""
Print ""
Print " Detassel Pay 1.0"
Print " By: Alex Briner"
Print " (Made for the "
Print " S&J Detasseling company)"
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print ""
Print " CopyRight 2003 By:"
Print " EveWare and Alex briner"
PSet (10, 10), 1
DRAW "r295 d170 l295 u170"
While INKEY$ <> "": Wend
While INKEY$ = "": Wend
Cls
Print " Main Menu"
Print ""
Print ""
Print ""
Print ""
Print "----------------------------------"
Print "| 1.Load | 2.New | 3.Edit | 4.Help"
Print "----------------------------------"
Print "Note: choose number"
INPUT "What is your choice?", choice%
If choice% = 1 Then GoTo Load
IF choice% = 2 THEN GOTO New
If choice% = 3 Then GoTo Edit
If choice% = 4 Then GoTo Help

Load:
Cls
Print "Loading Account........."
Print ""
Print ""
While INKEY$ <> "": Wend
While INKEY$ = "": Wend

New:
Cls
Print "Accout Creator"
Print ""
Print ""
Print ""
INPUT "How Many Hours did you work?", hours%
Print "5.15 per hour times"; hours%; "equals"; 5.15 * hours%
While INKEY$ <> "": Wend
While INKEY$ = "": Wend
Cls
Print "day 1 -"; 5.15 * hours%
Open "detassel.sav" For Output As #1
Print #1, detassel$

Edit:
Cls
Open "detassel.sav" For Input As #1
Input #1, detassel$
Print "account loaded"
INPUT "What is the day number of work?", daynum%
INPUT "How many hours were worked?", hrs%
Print "ok...."
While INKEY$ <> "": Wend
While INKEY$ = "": Wend
Cls
Print detassel$
Print daynum% - 5.15 * hrs%
Print ""
Print ""
Print "saving info..."
Open "detassel.sav" For Output As #1
Print #1, detassel$



Help:
Cls
Print "Detasseling money calculator by Alex Briner"
ok, i can't help you with your problem, but i have one question for you...

Have you ever heard of the command "locate"
Try putting this into qbasic?


Code:
screen 13
cls
locate 3,11: Print " Detassel Pay 1.0"
locate 4,12:Print " By: Alex Briner"
locate 5,11:Print " (Made for the "
locate 6,8:Print " S&J Detasseling company)"
locate 21,11:Print " CopyRight 2003 By:"
locate 22,9:Print " EveWare and Alex briner"
Quote:Open "detassel.sav" For Output As #1
Print #1, detassel$

whose ass did you pull "detassel$" from? Tongue
thi will return an empty string ""
you should write hours% to the file, or whatever it is you're trying to save
detassel is what i do at my job its called detasseling so i didnt get it outa no ones ass
Archangel,
Your prograam has several problems:

1) At the end of each section of your program (Load, New, Edit, Help), you need to do a goto back to the top where you display the menu. The way it is now, one routine just falls through to the next.
2) Also where you test for the 4 options, if it's not 1 to 4, you need to goto display the menu again.

3) The "Load" routine is obviously incomplete. It doesn't do anything now.

4) The "New" routine gets the hours, does a calculation, and prints it. Then it writes a string variable called Datassel$ to the output file, but nothing was ever put into Datassel$. Maybe the results of the calculation should be put into this variable.

5) Even when you've fixed the variable for the "New" routine, the way it's written will only allow for a total of one record on the Datassel.sav file. Maybe you should move the open of this output file up to the beginniing of the program.

6) The "Edit" routine also does not make any sense. You open
the file for input, and read the first record into datassel$. Then you get the daynum and hours, print a calculation, and then output the same old contents of Datassel$ to the output file.

7) By the way, you can't read and write onto the same text file as you do in the "Edit" routine. The file is still open for input as #1, and would give you an error when you open it for output as # 1. If you really wanted to do this, you would have to close #1 before the output as #1.

8. Your program looks strange in that it always works with the first record of the file Datassel.sav, both for input and output. I'm sure that you intend having more that one record on this file.

9) I think your program needs to operate on 2 versions of the Datassel file, an input version and an output version, like maybe Datassel.old and Datassel.new. Before running your program you would copy the newest Datassel.new to Datassel.old. After being updated by your program, Datassel.new would be the newest. You would then open both files once at the beginning of your program.

10) Is this program supposed to work for different people entering their hours worked? If so, then you need additional logic to have an employee number on the file, and to get the right record to update for a given employee.
*****
*****
Quote:1) At the end of each section of your program (Load, New, Edit, Help), you need to do a goto back to the top where you display the menu. The way it is now, one routine just falls through to the next.
ya i was gona do that but first i wana get the save and load thing and edit thing figured out and no this isnt gona b for anyone else to use just for me. im a noob at qbasic so im just foolin around and experimenting but it would b nice to make it a complete working program that i could use
Archangel, If you want this program just for foolin' around, that's fine. But if you want us to help you with it, it's got to have some sense of completion. Get what I mean?
*****
well of course it does i want it to b completed thats wat i said at the end i said it would b nice if it was a finished workin program and i would learn alot from doin this too.