I am writing a stock program and would like to check an assigned ?stock.dat? file as to make sure that the new stock number entered does not exist in the file. This is to avoid any duplication/redundancy. I need your assistance to guide me. For those who are expert in Pascal 7, please don?t hesitate to correct it as I am still a beginner.
{-------------------------
----------
----------
---------}
BEGIN
Assign(StockFile,'D:\Stock
.dat');
Stock_Prg; {stock program module}
END.
{-------------------------
----------
----------
---------}
Secondly, my stock program consist stock movement feature which can withdraw and replenish stock item.
I need to validate the option entered. If I chooses the withdrawal option, the program should:
1. prompt the user to input the stock number to withdraw the quantity form.
2. find the stock number entered in the file.
3. if the stock number not found, display an error message and prompt the user if he/she wants to continue again.
4. the quantity to withdraw is not more than quantity on hand and is not a negative value. Display an error message if so to inform the user.
5. otherwise subtract the withdrawal value from the quantity on hand and give new value to quantity on hand in the file.(update the quantity on hand)
6. prompt the user if he/she wants to continue withdraw other stock item.
If I chooses the replenish option, the program should:
1. prompt the user to input the stock number to replenish the quantity form.
2. find the stock number entered in the file.
3. if the stock number not found, display an error message and prompt the user if he/she wants to continue again.
4. if the stock number found, display the data about the stock no. Next prompt the user to enter the quantity to replenish.
5. the quantity to replenish is a logical value. Display an error message if it is not logical value to inform the user.
6. otherwise add the replenish value to the quantity on hand and give new value to quantity on hand in the file.(update the quantity on hand)
7. prompt the user if he/she wants to continue replenish other stock item.
Besides that, do I need to enter ?Val? procedure to perform the stock movement option? I just showed the important part and didn?t show the all of them such as the program menu code, display control code and etc. Thank you in advance.
{-------------------------
----------
----------
------}
TYPE
StockRecord = RECORD
StockNo : STRING[5];
StockDesc : STRING[35];
Price : REAL;
QtyOnHand : STRING[3];
Withdraw : STRING[3];
Replenish : STRING[3];
END;
VAR
EnterStkNo, EnterDesc, EnterPrice, EnterQty : Boolean;
No, StkNum, QtyNum: Word;
StrPrice: String;
Val(StockNo, StkNum, No);
Val(QtyOnHand, QtyNum, No);
Val(StrPrice, Price, No);
{-------------------------
----------
----------
-----}