ScriptSpot

Forum topic · General Scripting

forLoop to limit

By JokerMartini · 2011-10-06

Description

I’m trying to write a rather more than simple for-loop here.....

My frame range for example is (-50 1220)
Im wanting a function that does this ( for every 100 frames print “the batch number and the frame number”
the batch number corresponds to groups of 100 frames. The first 100 frames would be batch group 1. The second group of 100 frames would be batch number 2.

examples: (batch# + “_” + frame#)

1_50
1_51
1_52
1_....

2_151
2_152
2_153
2_....

Kinda have something going here but not completely there yet.


loops = (ceil (150/100.0)) as integer
	
for i =1 to loops do (
	for o = 1 to 100 do (
		print (i as string+ "_" + o as string)
	)	
)
Comments (1)

try this

Anubis · 2011-10-06

(
	local sFrame = -50, eFrame = 1220
	local seqSize = 100, itrNum = 0
	local seqNum = 1, prefix = "1_"
	local frmCount = eFrame - sFrame + 1
	local strArray = #()
	strArray[frmCount] = null
	
	for i = sFrame to eFrame do (
		itrNum += 1
		strArray[itrNum] = prefix + i as string
		if mod itrNum seqSize == 0 do (
			seqNum += 1
			prefix = seqNum as string + "_"
		)
	)
	
	print strArray
)