All pastes #977686 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-09 00:22 UTC
rendered paste body
BEGIN {
while ($0 != "2") {
printf "1. Enter a New Item\n";
printf "2. Display Inventory\n";
printf "Enter Choice: "
getline;
UserSel = $0
if (UserSel == "1") {
while ($0 != "n") {
        printf "Enter a New Item\n";
        printf "Enter the part number: ";
        getline;
        ThisItem[0] = $0;

        printf "Enter the manufacturer: ";
        getline;
        ThisItem[1] = $0;

        printf "Enter a description: ";
        getline;
        ThisItem[2] = $0;

        printf "Enter the wholesale cost: ";
        getline;
        ThisItem[3] = $0;

        printf "Enter the retail cost: ";
        getline;
        ThisItem[4] = $0;

        printf "Enter the stock count: ";
        getline;
        ThisItem[5] = $0;

        for (i = 0; i <= 5; i++) {
                if (ThisItem[i] == "") {
                        ThisItem[i] = "-";
                }
        }

        printf "Formated data: "
        Write="tee -a inventory.data"
        for (i = 0; i <= 5; i++) {
                if (i == 5) {
                        printf ThisItem[i] | Write;
                }
                else {
                        printf ThisItem[i]":" | Write;
                }
        }
        printf "\n" | Write;
        printf "Enter a new item? y/n: ";
        getline;
        close(getline);
}
}
}
}
END {
printf ("%-11s %-14s %-20s %16s %13s %+13s\n\n","Part Number","Manufacturer","Description","Wholesale Cost","Retail Cost","Stock Count");
}