Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh integer variable assignment

Status
Not open for further replies.

alfie002

Technical User
Joined
Mar 3, 2004
Messages
121
Location
GB
Dear all,

I have got a bit of a mind block at the moment. Can anyone tell me why this KSH code isn't working ?

if [ ${CurrentBackup} == 0]; then
PreviousBackup = (10 - (${CurrentNumber} - 1))
else
PreviousBackup = (${CurrentNumber -1 )
fi

All the variables fines, I get an error message complaining about the "(" on line 1.

Thanks

Alf
 
Hi

Code:
if ((CurrentBackup==0)); then
  PreviousBackup=$((10-(CurrentNumber-1)))
else
  PreviousBackup=$((CurrentNumber-1))
fi
Tested with (pd)[tt]ksh[/tt].

Feherke.
 
Another syntax :
Code:
integer CurrentBackup PreviousBackup CurrentNumber

if ((CurrentBackup==0)); then
  (( PreviousBackup=10-(CurrentNumber-1) ))
else
  (( PreviousBackup=CurrentNumber-1 ))
fi


Jean-Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top