PDA

View Full Version : Saving



PJYelton
12-03-2002, 12:46 PM
I've just started scripting and have written a small prog that playes blackjack with the user. What I was wondering, how would I make it so the game saved the amount of money the user won and then loaded this amount the next time the game is played?

PJYelton
12-03-2002, 03:10 PM
Um.. I know how to save in C and C++, but I don't know how to do it in Unix scripting which is what the program is written with.

Hammer
12-03-2002, 06:19 PM
Here's one way


SCORE=10

echo "SCORE is $SCORE"

echo $SCORE>score.txt

SCORE=0

echo "SCORE is $SCORE"

if [ -f score.txt ]
then
SCORE=$(cat score.txt)
fi

echo "SCORE is $SCORE"

PJYelton
12-03-2002, 07:22 PM
Thanks! Worked perfectly!