
-----------------------------------
HelloWorld
Tue Nov 09, 2004 6:18 pm

How can I have the FOR LOOP output what loop it is on..?....
-----------------------------------
How can I have the FOR LOOP output what loop it is on..?....

I need my FOR LOOP to output which loop it is on so I can state which part number it is...


    for counter : 1 .. n

        put "", skip
        put "PART", n %?? How can I do this?
        put "What is the part number? " ..
        get part (counter)

        put "How many of this part were purchased? " ..
        get quantity (counter)

        put "What is the parts name? " ..
        get pname (counter) : *

        put "What is the Net price of this part? " ..
        get netprice (counter)

        put "What is the Unit price for this part? " ..
        get price (counter)

    end for


Can anyone help me out with this?  Thanks.

-----------------------------------
wtd
Tue Nov 09, 2004 6:24 pm

Re: How can I have the FOR LOOP output what loop it is on..?
-----------------------------------
How can I have the FOR LOOP output what loop it is on..?....

I need my FOR LOOP to output which loop it is on so I can state which part number it is...


    for counter : 1 .. n

        put "", skip
        put "PART", n %?? How can I do this?
        put "What is the part number? " ..
        get part (counter)

        put "How many of this part were purchased? " ..
        get quantity (counter)

        put "What is the parts name? " ..
        get pname (counter) : *

        put "What is the Net price of this part? " ..
        get netprice (counter)

        put "What is the Unit price for this part? " ..
        get price (counter)

    end for


Can anyone help me out with this?  Thanks.

The "counter" variable is already doing that for you.

-----------------------------------
HelloWorld
Tue Nov 09, 2004 6:35 pm


-----------------------------------
Ha, sorry, I really should think harder before asking questions.  Thanks though, it was easy (counter : n)...

-----------------------------------
HelloWorld
Tue Nov 09, 2004 6:38 pm


-----------------------------------
Actually, I still have a problem, when I use:


put "PART", counter : n


It works well, but depending on the value of 'n', it spaces out "PART" and the number....  like the higher the value of 'n' the more spaces there are between "PART" and the number.... How can I keep it just one spacing?

-----------------------------------
Hikaru79
Tue Nov 09, 2004 6:44 pm


-----------------------------------
Remember, Letters are Left-aligned, numbers are right-aligned. As n increases, the "counter" has a larger field space to itself; and since it's at the right side of the field, it'll be farther away from "Part". For just ONE space, use:


put "Part ", counter


-----------------------------------
HelloWorld
Tue Nov 09, 2004 6:49 pm


-----------------------------------
Thanks for the help.  And by the way......


Letters are Left-aligned, numbers are right-aligned


I didn't know that, thanks again for the new knowledge!
