// Script to add a record loop
// Arguments:  
//	    Note: using userArgs. userArgs are passed by typing numbers in the main window. Arguments are separated by semi-colon
//		1: start of loop in bar
//		2: length of loop in bar
//
// Author: LoopToGo

//setting default values
variable loopStart $songBar + .999 1	// + .999 1 is for quantize to next bar (using .999 to stay on same bar if at beginning)
variable loopEnd 0				// Will be set properly in validation

// Getting first arg
if $userArg1
	variable loopStart $userArg1
endIf

// Validation
if $loopStart < 1
	// Back to default value
	variable loopStart $songBar
endIf


// Getting second arg
if $userArg2
	variable loopEnd $loopStart + $userArg2
endIf


//Important: we must erase userArgs so it's ready for the next input

setUserArgs

// Validation
if $loopEnd < $loopStart
	// Back to default value
	variable loopEnd $loopStart + 1
endIf


// Creating record loop

addRecordLoop $selectedTrack Record $loopStart $loopEnd

