HELP (VFP3) My Loop Doesn't Loop?

HELP (VFP3) My Loop Doesn't Loop?

Post by Wei Zhan » Fri, 26 Dec 1997 04:00:00



I have more than 10 procedures stored in a PRG file. I designed a form with
matching check boxes so that users can select report (procedures) to run as

*    frmMMMB.cmdReport.Click()
*
SET PROCEDURE TO procfile
WITH THIS.PARENT
    FOR X=1 TO 10
        cX=ALLTRIM(STR(X))
        cControl=".CHECK"+cX+".VALUE"
        cRPT="RPT"+cX
        IF &cControl=1
            DO cRPT
        ENDIF
    ENDFOR
ENDWITH

The loop only excutes once, that is no matter how many check boxes were
checked, only the first report was processed. The loop simply jumps out
afterward.

It has nothing to do with "Visual" as I tried in non visual PRG file the
problem is still there. It is nothing wrong with the loop structure itself
since as soon as I disabled the do procedure command the loop runs fine. It
is OK with all the procedures in the PRG file when I wrote a separate PRG
file with DO procnames for each report. Every single one of them runs
perfectly.

So you see, I really don't know what is wrong here. It could be either a
hiden trick that I am not aware of, or I have made simple stupid mistake?

Please help me out.

 
 
 

HELP (VFP3) My Loop Doesn't Loop?

Post by RMorse06 » Fri, 26 Dec 1997 04:00:00


{ SET PROCEDURE TO procfile
{ WITH THIS.PARENT
{     FOR X=1 TO 10
{         cX=ALLTRIM(STR(X))
{         cControl=".CHECK"+cX+".VALUE"
{         cRPT="RPT"+cX
{         IF &cControl=1
{             DO cRPT
{         ENDIF
{     ENDFOR
{ ENDWITH
{
{ The loop only excutes once, that is no matter how many
{ check boxes were checked, only the first report was
{ processed. The loop simply jumps out afterward.

Do you have something in "cRPT" that is changing the value of "X" to a number
greater than 10? This would throw you out of the loop as soon as the first
report was processed.

Ralph Morse
==================================
ICQ # 2016249

http://members.aol.com/RMorse0620/
==================================

 
 
 

HELP (VFP3) My Loop Doesn't Loop?

Post by Anders Altbe » Sat, 27 Dec 1997 04:00:00




> *    frmMMMB.cmdReport.Click()
> *
> SET PROCEDURE TO procfile
> WITH THIS.PARENT
>     FOR X=1 TO 10
>         cX=ALLTRIM(STR(X))
>         cControl=".CHECK"+cX+".VALUE"
>         cRPT="RPT"+cX
>         IF &cControl=1
>             DO cRPT
>         ENDIF
>     ENDFOR
> ENDWITH

> The loop only excutes once

Hi Wei
  You don't have a declaration
   LOCAL x, cx, cControl, cRPT
  so if any of them are public variables they could possibly be
  changed somewhere else, in cRPT?
 I changed DO cRPT to MessageBox(cRPT) and the loop works as planned.
 But if I call a procedure in which there's a line
   X=10
 then that finishes the loop.

-Anders

--

12/26/97 02:45
---------
Using: OUI 1.8 Beta 7 from http://www.peaktopeak.com

 
 
 

HELP (VFP3) My Loop Doesn't Loop?

Post by Wei Zhan » Sat, 27 Dec 1997 04:00:00


>Do you have something in "cRPT" that is changing the value of "X" to a
number
>greater than 10? This would throw you out of the loop as soon as the first
>report was processed.

>Ralph Morse
>==================================
>ICQ # 2016249

>http://members.aol.com/RMorse0620/
>==================================

Thank you very much Ralph. That is a very good point. I do have a variable X
in my procedure file. I think that is exactly where things went wrong. This
lesson will remind me for the rest of my life.
 
 
 

1. Need help with a loop script (won't loop)

Hi and thanks in advance

Sorry but got stocked in this problem.

Here is what I'm trying to do is.
From 4 FMP DB.
(participants.fp5, Questions.fp5, Test.fp5 and selected Questions.fp5)

I start out from within Participants.fp5 and generate ( script wise ) new
record in Test.fp5 and uses "set field" to define User_ID and test type.

Her I can manually ( through a value list ) in a portal row select the test
Questions, but only one by one.

I want to automate this !! so that all question that match a find (java) in
Question.fp5 would be generated in selected Questions.fp5

I use 2 scripts to try to accomplish this.

1. is in Questions.fp5 and produce a find. (works)

2. is in Test.fp5 and should produce a loop I think ??
   It doesn't work properly, it only generate 1 Selected Question in the
   portal row and stops.
-----------------------------
Go to Portal Row [First]
Loop
    Set Field ["Selected Question :: Question_ID","Questions::Question_ID"]
    Perform Script [Sub-scripts,External:"Questions.fp5"]
    Go to Record/Request/page [exit after last, Next]
End loop
-----------------------------

Is this a totally wrong approach to my issue. ????

Any idea or clue is appreciated

Lars Luciano Arlr               - Graphic Designer & Systems Architect

2. CA/Ingres Tech Support Experience

3. Help Help For Loops and incrementing fields each loop

4. String parsing in stored procedure

5. Comand object in a loop doesn't work

6. B+-tree for OODB indexing?

7. Looping within a Loop

8. D3 and autodialing with NT RAS

9. Loops will not loop any more

10. VFP3 - Wizards start endless loops?

11. TRIGGER HELP : How to LOOP 'til EOF

12. Need a Loop Expert's Help

13. 'ORA-01436: CONNECT BY loop in user data' - how can I find the loop ?