Page 1 of 1

Variable Test in Macro

PostPosted: Wed Jan 02, 2013 11:43 am
by ORWoody
I would like to work on a little macro for drawing stairs in a straight run. Nothing particularly complex, but one of the variables would be the number of risers. How does one test for repeats for until done in DCAL?
Thanks much,
Woody

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 1:40 pm
by David A. Giesselman
How about a FOR, WHILE or REPEAT loop?

Dave

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 2:06 pm
by ORWoody
Thanks much for those options. I knew about them as tests, but am not clear on how to re-direct. In basic, I just used a line identifier to force the return to Do/Until. Is the method similar in DCAL?
Thank you,

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 2:11 pm
by ORWoody
Would While work like If in this case? If so, could I then have a sub-routine that just drew the next riser and called the While again?

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 2:39 pm
by David A. Giesselman
You can't call the While loop back from the sub-routine (function). You'd want to do something like:
Code: Select allvar
   Current_Riser : integer;

Current_Riser := 1;
WHILE (Current_Riser <= Num_Risers) DO
   { *** Call your function to draw the riser here *** }
   Current_Riser := Current_Riser + 1;
END;

Dave

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 3:10 pm
by ORWoody
Excellent. That explains exactly what I needed.
I appreciate it.

Re: Variable Test in Macro

PostPosted: Wed Jan 02, 2013 3:27 pm
by David A. Giesselman
No problem Woody!

Dave

Re: Variable Test in Macro

PostPosted: Thu Jan 03, 2013 12:02 pm
by ORWoody
I have a dcs file written out and during DCC1, I end up getting a simple error message in regards to a semicolon being needed to end a statement. For the life of me, I can't find where one is missing. I go to the line identified and search above, but nothing jumps out at me. If there is anyone willing to assist me with this, I would be grateful.
Warning: I am a bit like a cat that has been fed at the back door. Once helped, I continue begging until done. I'd like to be more proficient at DCAL, but can never seem to move beyond the basics on my own.
Thank you,

Re: Variable Test in Macro

PostPosted: Thu Jan 03, 2013 5:05 pm
by David A. Giesselman
Send it to me Woody.

Dave

Re: Variable Test in Macro

PostPosted: Wed Jan 09, 2013 10:36 am
by ORWoody
In order to get the WHILE to work, I assume that it must be part of an independent procedure that initiates the DO for each riser. Would one of you real programmers look at this and tell me why I get an error message indicated for a redefined symbol for Current_Riser : integer?

!--------------------------------------------------------------
PROCEDURE risernum (current_riser, num_risers : IN integer);
VAR
Current_Riser : integer;
BEGIN
Current_Riser := 1;

WHILE (Current_Riser <= Num_Risers) DO
do_sections;
Current_Riser := Current_Riser + 1;
END;
END
END risernum;
!--------------------------------------------------------------

Thank you,

Re: Variable Test in Macro

PostPosted: Wed Jan 09, 2013 10:59 am
by David A. Giesselman
Answered via email.

Dave