FOR loop

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
matenek
Posts: 17
Joined: November 17th, 2022, 12:57 am

FOR loop

Post by matenek »

Hello community.
I need to ask how many buildings there are in a school and for each building, fill in the same questions.

what the number of buildings of school? nr_buildings

if nr_buildings = 3
run loop 3 times with the same questions:
q1
q2
q3
q4
q5
end loop

Has anyone implemented this in cspro? what is the best way to receive the value in a variable and make the loop bringing the same questions to each building?

Best ;)
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: FOR loop

Post by Gregory Martin »

Typically you'd create a record for these building questions and then make the record repeat: https://www.csprousers.org/help/CSPro/occurrences.html

The NR_BUILDINGS value would not be on the repeating building record, as you're only asking that once. Then in Q1, you'd have a check, something like:
PROC Q1

preproc

    if curocc
() > NR_BUILDINGS then
        endgroup
;
    endif;
matenek
Posts: 17
Joined: November 17th, 2022, 12:57 am

Re: FOR loop

Post by matenek »

Hi Gregory,
I already implemented your suggestion in tests and now works fine.

Thanks a lot.
Post Reply