GDL
About building parametric objects with GDL.

Goto inside For Next loop that jumps outside of the loop causes problem.

Anonymous
Not applicable
Hi, I would like to ask how I can rewrite the following code so I do not get a crossing loops error.
If I use endif I get error endif without if.
If I do not use it I get Next without For at label 4310
4280: FOR I=1 TO N
	  FOR J=1 TO FK
	  IF ABS(Q-EPS) >= EPS GOTO 4300 
	  NEXT J
!     ENDIF
4290: GOTO 4310	
4300: TEXT2 0,-9-N-NS-I,I
	  FOR H=1 TO FK
	  TEXT2 3*H,-9-N-NS-I,Q						
	  NEXT H                                                
4310: NEXT I
Thanks in advance.
13 REPLIES 13
Anonymous
Not applicable
I think the difference of the initial post to my last post is that in the first loop just checks if in the column exist ANY value and then prints column number and the contents of the column.

Whereas with my last post it will print the row for any value it finds greater than zero. So if a column has more values greater than zero as many rows will be printed.

How I can fix that?
You are welcome Ioannis,
you need and "endif" after "else" otherwise you will get an error
if you want it to jump to the next column when if finds a "0" value then you need to do this:

FOR I=1 TO N
	  FOR J=1 TO FK
	            IF ABS(Q) >= EPS THEN
	                             TEXT2 0,-9-N-NS-I,I
	                  FOR H=1 TO FK
	                              TEXT2 3*H,-9-N-NS-I,Q							
	                  NEXT H  
                     ELSE
	                  J = FK   !this will stop it cycling through this column and jump to the next column
                     ENDIF
          NEXT J                                              
NEXT I
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
Anonymous
Not applicable
Thanks Kristian it worked. There was just a little difference, I wanted to check if the column had values greater than zero then print the column number and column data. So I just had to move the J reset statement before ELSE.
FOR I=1 TO N
	  FOR J=1 TO FK
	            IF ABS(Q) >= EPS THEN
	                             TEXT2 0,-9-N-NS-I,I
	                  FOR H=1 TO FK
	                              TEXT2 3*H,-9-N-NS-I,Q							
	                  NEXT H  
	                  J = FK   !this will stop it cycling through this column and jump to the next column
                     ELSE

                     ENDIF
          NEXT J                                              
NEXT I
cool, glad you got it working.
if there is not function between the "else" and "endif" then you don't need the "else".
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists