Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

for i = 1 HELP

JGoode
Expert
Is there a way to use this statement but modify it to use 1 less than "num_bays"???
		for i = 1 to num_bays
			if strstr(bay_type, 'Car') then gosub "Draw Bay"
			if strstr(bay_type, 'PTW') then gosub "Draw Bay"
			if strstr(bay_type, 'Cycle') then gosub "Draw Cycle"
			
			add A,0, 0	! Move to next space


Thanks
ArchiCAD 23

Windows 10
5 REPLIES 5
Dave Seabury
Advocate
FOR I = 1 TO num_bays - 1

David
AC 19-26 Windows 10 64 bit, Dell Prercision 7820, Xeon Silver 2414R ( 12 Cores), 64 GB Ram, Quadro RTX 4000 8GB
JGoode
Expert
Dave wrote:
FOR I = 1 TO num_bays - 1

David
I tried this but no luck. I just made a num_bays_2 parameter and made it equal num_bays - 1 and it worked correctly.
ArchiCAD 23

Windows 10
Dave Seabury
Advocate
J

I use this quite a bit, the only thing I can think of is
"num_bays" has to be declared before the script is
run ie it needs f to be a parameter or defined in the
master script

ds
AC 19-26 Windows 10 64 bit, Dell Prercision 7820, Xeon Silver 2414R ( 12 Cores), 64 GB Ram, Quadro RTX 4000 8GB
David Maudlin
Rockstar
JGoode:

Another option is to start at 2:
for i = 2 to num_bays
You should add a Signature to your Profile (click the Profile button near the top of this page) with your ArchiCAD version and operating system (see mine for an example) for more accurate help in this forum.

David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC28 USA • Mac mini M4 Pro OSX15 | 64 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
JaseBee
Advocate
Not sure if this is relevant to your exact problem, but there doesn't seem to be any function for switching your "bay_type" from one "i" value to the next. If they are all supposed to be the same bay type then it might be better to do your string check outside the loop so it only needs to be calculated once.

Also the strstr() function returns the integer position of the string within the string, so it might be advantageous to add ">0" to your "if strstr() then" statement, ie. "if strstr(bay_type, "Cars") > 0 then" just to avoid any funny business...

Sorry, just procrastinating my own coding issues atm.

As for the problem, I've never had any issue with the "num_bays - 1" approach, not sure what could be at issue there.
AC 24 5004 AUS
iMac OSX (10.13.6) 4.2ghz i7
8gb ram/8gb vram