Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 14th, 2007, 10:41 AM   #1
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 343
Rep Power: 4 cwl157 is on a distinguished road
graphing in bash

I have to make a graph using bash and i have a weird thing going on. If i set the x and y indexes to 0 it will graph the first point, however, if i try to increment them or change them to a different number it doesn't graph anything. The way i have it set up is a while loop that goes through the rows or y values and then a while loop inside of that goes through the x values. It is a 40 by 80 grid so those numbers are set. Here is the function that graphs. If anyone sees any errors as to why it would graph the first point ok, but then not any others, I would appreciate it. I know i am not incrementing the indexes anywhere because if i try that it doesn't graph anything. So i thought it was not graphing all the points because i wasnt incrementing the indexes right, but even if i set the indexes to 1 instead of 0 it won't graph the second point. Anyone see what i'm doing wrong?
function graph
{
    rows=40
    cols=1
    yIndexA=0    #go through y array
    xIndexA=0    #go through x array
    #gMinX=$(echo "scale=5 ; $minX - $1" | bc)
   # gMaxY=$(echo "scale=5 ; $maxY + $2" | bc)

############################################################################
    #loop through y values
    while [ "$rows" -gt 0 ]
    do
      #gMaxY=$(echo "scale=5 ; ($gMaxY - $2)" | bc)
     # blankSpacesDown=$(echo "scale=5 ; (${yValues[yIndex]} - $gMaxY - 1)" | bc)
      #printSpacesDown $blankSpacesDown
      #echo -n ${yValues[yIndex]}
      #echo -n $gMaxY

      #(( yIndex++ ))
      echo

      # reset things for innner loop
      cols=1
      xIndexA=0

     ##########################################################################
     #loop through x values
     while [ "$cols" -lt 81 ]
     do
       #gMinX=$(echo "scale=5 ; ($gMinX + $1)" | bc)
       #blankSpaces=$(echo "scale=5 ; (${xValues[xIndex]} - $gMinX - $1)" | bc)
       #printBlankSpaces $blankSpaces
       #printBlankSpaces 4
        #echo -n ${convertedYValues[yIndex]} " "
        #echo -n ${convertedXValues[xIndex]} " "
        #varX=${convertedXValues[xIndex]}
        #varY=${convertedYValues[yIndex]}
        #echo -n $rows " "
        #echo -n $cols " "

       if [ "$cols" == "${convertedXValues[xIndexA]}" ]
       then
         if [ "$rows" == "${convertedYValues[yIndexA]}" ]
         then
           echo -n "X"
         fi
         else
           echo -n " "
       fi
       #echo -n ${xValues[xIndex]} " "
       #echo -n $gMinX

        #(( xIndex++ ))
       #(( yIndex++ ))
       (( cols++ ))
    done  # loop through x
    #(( yIndex++ ))
    (( rows-- ))
  done # loop through y
  echo

}  # end graph function
cwl157 is offline   Reply With Quote
Old Apr 14th, 2007, 11:34 AM   #2
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 343
Rep Power: 4 cwl157 is on a distinguished road
i got it, the comparisons were wrong change them to -le for less than or equal to and make it 80 and then change it to -ge for greater than or equal to and make it 0. This will graph any point i put in. So if i make the indexes 1 then it will print the point at x array is 1 and y array is 1. Now i just have to figure out where to increment the indexes.
cwl157 is offline   Reply With Quote
Old Apr 14th, 2007, 6:16 PM   #3
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 343
Rep Power: 4 cwl157 is on a distinguished road
got it you just have to increment the xIndex and yIndex inside of the if statement when a value is found
cwl157 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I call a bash script in C? smile_sunshine C 8 Apr 30th, 2006 9:36 PM
Bash or Perl? titaniumdecoy Other Scripting Languages 9 Jan 30th, 2006 4:42 PM
Do you use perl over bash scripting? linuxpimp20 Perl 3 Sep 12th, 2005 2:29 PM
Window Re-sizing in bash script. Huck Bash / Shell Scripting 1 May 1st, 2005 5:31 PM
Using Date in Bash Scripting raghavendra Bash / Shell Scripting 13 Apr 11th, 2005 11:23 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:54 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC