Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org For Statement
 Linux - General This Linux forum is for general Linux questions and discussion. If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

 10-31-2004, 04:33 PM #1 bendeco13 Member   Registered: Oct 2004 Distribution: Fedora 7 Posts: 232 Rep: For Statement Does any one know whats why this won't work: Code: for COLOR in x1 y1 x2 y2 x3 y3 do if [ \$COLOR -ge 10 ]; then if [ \$COLOR == 10 ]; then \$COLOR=A elif [ \$COLOR == 11 ]; then \$COLOR=B elif [ \$COLOR == 12 ]; then \$COLOR=C elif [ \$COLOR == 13 ]; then \$COLOR=D elif [ \$COLOR == 14 ]; then \$COLOR=E elif [ \$COLOR == 15 ]; then \$COLOR=F fi fi done Thanks in advance!!
 10-31-2004, 04:44 PM #2 Tinkster Moderator   Registered: Apr 2002 Location: in a fallen world Distribution: slackware by choice, others too :} ... android. Posts: 23,067 Blog Entries: 11 Rep: How do you expect the string x1 to match against the integer 10? Cheers, Tink
 10-31-2004, 04:57 PM #3 bendeco13 Member   Registered: Oct 2004 Distribution: Fedora 7 Posts: 232 Original Poster Rep: Awwwww..... x1 was previously assigned a number, but it is supposed to call on the value that was previously assigned to x1, y1, x2 ...etc...etc... this code will give a better explanation of what I'm trying to do... Code: if [ \$x1 -ge 10 ]; then if [ \$x1 == 10 ]; then x1=A elif [ \$x1 == 11 ]; then x1=B elif [ \$x1 == 12 ]; then x1=C elif [ \$x1 == 13 ]; then x1=D elif [ \$x1 == 14 ]; then x1=E elif [ \$x1 == 15 ]; then x1=F fi fi so.... if x1 was previously defined as: x1=11 then x1 would obtain the value of B I'm trying to make this into a for loop so that it will do it for all of the different parts (y1, x2, y2, ...etc...etc). This will greatly shorten the length of the code... This clearly doesn't work: Code: for PART in x1 y1 x2 y2 x3 y3 do if [ \$\$PART -ge 10 ]; then ..... fi done I know there's a different way to do this? Last edited by bendeco13; 10-31-2004 at 05:00 PM.
 10-31-2004, 05:08 PM #4 bendeco13 Member   Registered: Oct 2004 Distribution: Fedora 7 Posts: 232 Original Poster Rep: Is there a way to use an aliases to assign the value to the pointer? like in the C language... you can use *variable to point to the location of variable
 10-31-2004, 05:11 PM #5 Tinkster Moderator   Registered: Apr 2002 Location: in a fallen world Distribution: slackware by choice, others too :} ... android. Posts: 23,067 Blog Entries: 11 Rep: Why not just: Code: for PART in \$x1 \$y1 \$x2 \$y2 \$x3 \$y3 do if [ \$PART -ge 10 ]; then ..... fi done Cheers, Tink
 10-31-2004, 05:12 PM #6 acid_kewpie Moderator   Registered: Jun 2001 Location: UK Distribution: Gentoo, RHEL, Fedora, Centos Posts: 43,417 Rep: Code: # this=that # the_other=this # echo \$the_other this # echo \$((the_other)) that that's the bit you're stuck on right?
 10-31-2004, 05:31 PM #7 bendeco13 Member   Registered: Oct 2004 Distribution: Fedora 7 Posts: 232 Original Poster Rep: THANKS ALOT..... That did part of it, but say I was doing this part: Code: for PART in x1 y1 x2 y2 x3 y3 do \$PART=A done This should assign A to x1, y1, x2, y2, x3, and y3....but it don't How could I do this?

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post mnauta Linux - Networking 1 08-19-2005 01:21 PM sk84blood813 Programming 3 12-09-2004 08:25 AM junjem0702 Programming 4 08-23-2004 09:49 AM linuxanswer Programming 2 11-29-2003 11:25 PM johnyy Linux - Software 1 11-02-2003 03:30 AM

All times are GMT -5. The time now is 08:14 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -