GTKdialog variable tests

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

GTKdialog variable tests

#1 Post by 8-bit »

How would one check to see if two variables were true before calling a function?
I know how to check one with

Code: Select all

If [ $CBOX3 = "true" ] ;then #Checkbox checked for USB
if [ $CBOX4 = "true" ] ;then #If Checkbox for internal drive is checked
if [ $CBOX1 = "true" ] ;then #Checkbox checked for format
run function
fi
fi
else
display message
fi
Also, $CBOX3 and $CBOX4 cannot both be true.
So how do I implement and or on them
Opps! that was three. But can I shorten that.
But can I combine them with an and to signify both need to be true?
Suggestions welcome.

I am on the final lap of creating one program that will format both internal and USB floppy disks.
Last edited by 8-bit on Thu 22 Oct 2009, 07:30, edited 1 time in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

Please teach yourself to indent your code for better readability.

Code: Select all

If [ $CBOX3 = "true" ] && [ $CBOX4 = "true" ] ;then  
   if [ $CBOX1 = "true" ] ;then 
      run function 
   fi 
else 
   display message 
fi
Or:

Code: Select all

If [ $CBOX3 = "true" -a $CBOX4 = "true" ] ;then  
   if [ $CBOX1 = "true" ] ;then 
      run function 
   fi 
else 
   display message 
fi

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#3 Post by 8-bit »

As Gomer Pyle said,
Thank you.
Thank you.
Thank you.

That bit of information helped in finalizing the program other than going back through and indenting.
As you might of gathered, I am a hit and miss programmer.
I try something and keep changing it until it works.

But the final result is a program that will format both internal floppy disks and external USB floppy disks.

It might even be good enough for inclusion in a new Puppy release.

I had previously uploaded 2 versions just for USB drives.
This one goes beyond that.

Thanks again! :-)

Post Reply