
;virtual scenes functions version 1.1

	SET functionstring, "#<functionstring>vs=1.1-"
	GOTO @vsafter

@separateHyphens
	SET_LEN stringlen, #<string>
	SET readpoint, "0"
	SET lastoff, "0"
	SET currstr, "1"
@soulreadloop
		SET_SUBSTR chartest, #<readpoint>, 1, #<string>
		STRCMP "-", "#<chartest>"
		IF= @strgrab1
		ADD readpoint, "1"
		COMPARE #<stringlen>, "#<readpoint>"
		IF> @soulreadloop
		SUB readpoint, "#<rearoff>"
		SUB readpoint, "1"
		SET_SUBSTR soul#<currstr>, #<rearoff>, #<readpoint>, #<string>
		ADD currstr, "1"
		ADD readpoint, "#<rearoff>"
		ADD readpoint, "2"
		SET rearoff, "#<readpoint>"
		ADD readpoint, "1"
		COMPARE #<stringlen>, "#<readpoint>"
		IF> @soulreadloop
	SUB currstr, "1"
	SET souls, "#<currstr>"
	RETURN #<souls>


@vsripdata
	SET_SUBSTR vs2242currlength, #<vs2242readpoint>, 3, #<vs2242commands>
	ADD vs2242readpoint, "3"
	SET_SUBSTR vs2242return, #<vs2242readpoint>, #<vs2242currlength>, #<vs2242commands>
	ADD vs2242readpoint, "#<vs2242currlength>"
	RETURN #<vs2242return>
	END


@vsdenest
	SET numiterations, "#<arg0>"
	SET i, 9
@vsdenestgrabloop
	PUSH arg#<i>
	POP nested#<i>
	SUB i, 1
	COMPARE #<i>, 0
	IF> @vsdenestgrabloop
@vsdenestiloop
	ADD i, 1
	SET string, nested#<i>
	SET string, *#<string>
	SET first,	""
	SET offset, "-1"
	SET_LEN maxoff, #<string>
	SUB maxoff, 2
@vsdenestloop
		ADD offset, "1"
		SET_SUBSTR strtest, #<offset>, 2, #<string>
		STRCMP "#<strtest>", "#<"
		IF= @vsdenestcall
		COMPARE #<offset>, #<maxoff>
		IF< @vsdenestloop
	SET vsdenestreturn#<i>, #<string>
	COMPARE #<i>, #<numiterations>
	IF< @vsdenestiloop
	RETURN #<i>, #<vsdenestreturn1>, #<vsdenestreturn2>, #<vsdenestreturn3>, #<vsdenestreturn4>, #<vsdenestreturn5>, #<vsdenestreturn6>, #<vsdenestreturn7>, #<vsdenestreturn8>, #<vsdenestreturn9>

@vsdenestcall
	SET_LEN strlen, #<string>
	SUB strlen, #<offset>
	SET_SUBSTR first, 0, #<offset>, #<string>
	SET_SUBSTR denest, #<offset>, #<strlen>, #<string>
	SUB offset, 1
	SET_SUBSTR strtest, #<offset>, 1, #<string>
	STRCMP #<strtest>, "*"
	IF= @vsdenest2call
	CALL @vsdenest1go #<denest>, 1
	SET_LEN denestlen, #<arg0>
	SET_LEN offset, #<first>
	ADD offset, #<arg1>
	SUB offset, 1
	SET string, #<first>#<arg0>
	GOTO @vsdenestloop
@vsdenest2call
	SET_SUBSTR first, 0, #<offset>, #<string>
	CALL @vsdenest1go #<denest>, 2
	SET_LEN denestlen, #<arg0>
	SET_LEN offset, #<first>
	ADD offset, #<arg1>
	SUB offset, 1
	SET string, #<first>#<arg0>
	GOTO @vsdenestloop

@vsdenest1go
	PUSH multi
	PUSH first
	SET multi, "0"
	SET multi, #<arg1>
	SET offset, "1"
	SET string, "#<arg0>"
	SET_LEN maxoff, #<string>
	SUB maxoff, 1
@vsdenest1goloop
	ADD offset, 1
	SET_SUBSTR strtest, #<offset>, 2, #<string>
	STRCMP "#<strtest>", "#<"
	IF= @vsdenestcall1
	SET_SUBSTR strtest, 0, 1, #<strtest>
	STRCMP "#<strtest>", ">"
	IF= @vsdenest1
	COMPARE #<offset>, #<maxoff>
	IF< @vsdenest1goloop
	SET retstring, #<string>
	POP first
	POP multi
	RETURN #<retstring>, #<offset>
@vsdenestcall1
	SET_LEN strlen, #<string>
	SUB strlen, #<offset>
	SET_SUBSTR first, 0, #<offset>, #<string>
	SET_SUBSTR denest, #<offset>, #<strlen>, #<string>
	SUB offset, 1
	SET_SUBSTR strtest, #<offset>, 1, #<string>
	STRCMP #<strtest>, "*"
	IF= @vsdenest2call1
	CALL @vsdenest1go #<denest>
	SET_LEN denestlen, #<arg0>
	SET_LEN offset, #<first>
	ADD offset, #<arg1>
	SUB offset, 1
	SET string, #<first>#<arg0>
	GOTO @vsdenest1goloop
@vsdenest2call1
	SET_SUBSTR first, 0, #<offset>, #<string>
	CALL @vsdenest1go #<denest>, 2
	SET_LEN denestlen, #<arg0>
	SET_LEN offset, #<first>
	ADD offset, #<arg1>
	SUB offset, 1
	SET string, #<first>#<arg0>
	GOTO @vsdenest1goloop

@vsdenest1
	SUB offset, 2
	SET_SUBSTR denest, 2, #<offset>, #<string>
@vsdenest1loop
	PUSH #<denest>
	POP denest
	SUB multi, 1
	COMPARE #<multi>, 0
	IF> @vsdenest1loop
	ADD offset, 3
	SET_LEN denestlen, #<denest>
	SET_LEN strlen, #<string>
	COMPARE #<offset>, #<strlen>
	IF= @vsdenest1returnvalue
	SET_SUBSTR string, #<offset>, #<strlen>, #<string>
	SET string, #<denest>#<string>
	POP first
	POP multi
	RETURN #<string>, #<denestlen>
@vsdenest1returnvalue
	POP first
	POP multi
	RETURN #<denest>, #<denestlen>


@drawvscommandlist ; CALL @drawvscommandlist startcommand
	SET num.DevTableId, "90"
	SET currnum, "#<arg0>"
	SET currid, "7"
	SET actorheight, "25"
@vscommandlistdrawloop
		SET str.DevTableRowId, "#<currnum>"
		SET curractor, "#<str.DevTableCOL3>"
		SET actorskinnum, "#<curractor>"
		SET actoroff, "#<curractor>"
		DIV actorskinnum, "20"
		MOD actoroff, "20"
		ACTOR #<currid>, "#<str.DevTableCOL1> Command", VSlistbuttons#<actorskinnum>, #<actoroff>, 62, #<actorheight>, #<str.DevTableCOL2>
		SET actor#<currid>, "#<curractor>"
		ADD currid, "1"
		ADD currnum, "1"
		SET str.DevTableRowId, "#<currnum>"
		SET curractor, "#<str.DevTableCOL3>"
		SET actorskinnum, "#<curractor>"
		SET actoroff, "#<curractor>"
		DIV actorskinnum, "20"
		MOD actoroff, "20"
		ACTOR #<currid>, "#<str.DevTableCOL1> Command", VSlistbuttons#<actorskinnum>, #<actoroff>, 78, #<actorheight>, #<str.DevTableCOL2>
		SET actor#<currid>, "#<curractor>"
		ADD currid, "1"
		ADD currnum, "1"
		ADD actorheight, "10"
		COMPARE #<actorheight>, "95"
		IF!= @vscommandlistdrawloop
	RETURN success


;@drawcommands startcommand; RETURN success
@drawvscommands
	COMPARE #<vsguicommand>, "0"
	IF= @vscommandsdrawloopfin
	SET num.DevTableId, "90"
	SET index, "#<arg0>"
	SET currid, "0"
	SET actorheight, "25"
@vscommandsdrawloop
		SET curractor, "vsguicommand-#<index>"
		SET_SUBSTR curractor, 0, 2, *#<curractor>
		SET actor#<currid>, "#<curractor>"
		SET actorskinnum, "#<curractor>"
		SET actoroff, "#<curractor>"
		CALL @vsrevlookup #<curractor>
		SET curractor, #<arg0>
		DIV actorskinnum, "20"
		MOD actoroff, "20"
		SET str.DevTableRowId, "#<curractor>"
		ACTOR #<currid>, "#<str.DevTableCOL1> Command", VSlistbuttons#<actorskinnum>, #<actoroff>, 28, #<actorheight>, #<str.DevTableCOL2>
		SET actornum#<currid>, "#<index>"
		ADD currid, "1"
		ADD currnum, "1"
		ADD index, "1"
		COMPARE #<index>, "#<vsguicommand>"
		IF> @vscommandsdrawloopfin
		ADD actorheight, "10"
		COMPARE #<actorheight>, "95"
		IF!= @vscommandsdrawloop
@vscommandsdrawloopfin
	COMPARE #<currid>, "6"
	IF> @vscommandsdrawloopesc
	ACTOR #<currid>, "", VSbuttons, 0, -100, -100
	ADD currid, 1
	GOTO @vscommandsdrawloopfin
@vscommandsdrawloopesc
	RETURN success
	END


;@compilestring stringarray, commandarray; RETURN commandarray
@compilestring 
	SET write, #<arg1>-0
	SET #<write>, #<arg0>-0 ;copies the scene label over
	SET index, 0
	SET #<arg1>, 0
	SET writelen, 0
@compilestringloop
		;This chunk chops off preceding carats, an artifact of the imperfect string concatenation.
		COMPARE #<writelen>, 0
		IF= @compilestringloopcontinue ;If it's unnecessary (first time through the loop), skip the procedure
		SET_LEN writelen, *#<write>
		SUB writelen, 1
		SET_SUBSTR #<write>, 1, #<writelen>, *#<write>
	@compilestringloopcontinue
		ADD #<arg1>, 1
		SET write, #<arg1>-*#<arg1>
		SET #<write>, ""
		SET writelen, 0
	@compilestringwriteloop
			ADD index, 1
			SET read, #<arg0>-#<index>
			SET_LEN readlen, *#<read>
			ADD writelen, #<readlen>
			COMPARE #<writelen>, 255 ; See if current compilation string is getting too long
			IF> @compilestringloop ; If so, start a new one.
			SET #<write>, "*#<write>^*#<read>" ; Otherwise, add the current command string to the compilation string.
			COMPARE #<index>, *#<arg0> ; See if the compilation is complete
			IF< @compilestringwriteloop ; If not, add the next command string.
	RETURN #<arg1>

;@decompilestring commandarray, stringarray; RETURN stringarray
@decompilestring 
	SET write, #<arg1>-0
	PUSH #<arg0>-0
	POP #<write> ;copies the scene label over
	SET index, 0
	SET writeindex, 1
@decompilestringloop
		SUB writeindex, 1 ;So that the extra ADD later doesn't increase by two between array entries.
		ADD index, 1
		SET currtoken, -1 ;Token inside string.  0 on first read for each string.
		COMPARE #<index>, *#<arg0>
		IF> @decompilestringdone
		SET read, #<arg0>-#<index>
@decompilestringwriteloop
			ADD writeindex, 1 ;Without the SUB above, this could ADD but not then write to that index.
			ADD currtoken, 1
			NTH_TOKEN write, #<currtoken>, *#<read>, "^"
			STRCMP #<write>, "" ;Null string means that this compiled string is done, move to next one.
			IF= @decompilestringloop
			SET #<arg1>-#<writeindex>, #<write>				
			GOTO @decompilestringwriteloop
@decompilestringdone
	SET #<arg1>, #<writeindex>
	RETURN #<arg1>

;@uploadstring local, destcat, destvar; RETURN local
@uploadstring 
	SET_SERVER_VAR vs#<arg1>, #<arg2>, *#<arg0>
	SET index, -1
@uploadstringloop
	ADD index, 1
	PUSH #<arg0>-#<index>
	POP value
	SET_SERVER_VAR vs#<arg1>, #<arg2>-#<index>, #<value>
	COMPARE #<index>, *#<arg0>
	IF< @uploadstringloop
	RETURN #<arg0>

;@downloadstring local, remotecat, remotevar; RETURN local
@downloadstring 
	GET_SERVER_VAR #<arg0>, vs#<arg1>, #<arg2>
	SET index, -1
@downloadstringloop
	ADD index, 1
	GET_SERVER_VAR #<arg0>-#<index>, vs#<arg1>, #<arg2>-#<index>
	COMPARE #<index>, *#<arg0>
	IF< @downloadstringloop
	RETURN #<arg0>

;@openstring array, devTable, rowID; RETURN array
@openstring
	PUSH row
	PUSH maxindex
	PUSH index
	SET num.devTableID, #<arg1>
	SET row, #<arg2>
	SET str.devTableRowID, #<row>
	SET maxindex, #<str.devTableCOL1>
	SET index, 0
	COMPARE #<maxindex>, 0
	IF> @openstringloop
	RETURN
@openstringloop
	ADD index, 1
	SET str.devTableRowID, #<row>-#<index>
	SET #<arg0>-#<index>, #<str.devTableCOL1>
	COMPARE #<index>, #<maxindex>
	IF< @openstringloop
	SET #<arg0>, #<index>
	POP index
	POP maxindex
	POP row
	RETURN #<arg0>

;@printQUEST stringarray; RETURN null
@printQUEST 
	SET maxindex, *#<arg0>
	SET index, 0
	SET currlabel, #<arg0>-0
	SET array, #<arg0>
	N: <Begin Virtual Scene Output. Label: "*#<currlabel>">
@printQUESTloop
	ADD index, 1
	COMPARE #<index>, #<maxindex>
	IF> @printQUESTend
	PUSH #<array>-#<index>
	POP command
	SET_SUBSTR currAction, 0, 2, #<command>
	CALL @vsunpack #<command>

	STRSTR "-11-27-49-", "-#<currAction>-"
	IF> @printQUESTnoArgs
	STRSTR "-99-", "-#<currAction>-"
	IF> @printQUESTlineLabel
	STRSTR "-05-06-08-10-21-22-23-25-26-29-30-31-32-34-40-43-44-45-46-48-50-55-59-60-62-63-64-67-", "-#<currAction>-"
	IF> @printQUESTstdOneArg
	STRSTR "-02-03-07-09-12-13-14-15-16-17-18-37-39-52-53-56-57-58-61-66-69-70-71", "-#<currAction>-"
	IF> @printQUESTcommaArgs
	STRSTR "-24-28-47-51-", "-#<currAction>-"
	IF> @printQUESTthreeCommaArgs
	STRSTR "-38-54-", "-#<currAction>-"
	IF> @printQUESTfourCommaArgs
	STRSTR "-21-45-", "-#<currAction>-"
	IF> @printQUESTmultiArg
	STRSTR "-01-04-33-36-68-72-", "-#<currAction>-"
	IF> @printQUESTspecialCase
	STRSTR "-19-20-35-41-42-", "-#<currAction>-"
	IF> @printQUESTvararg
	END
@printQUESTnoArgs
	N: #<arg0>
	GOTO @printQUESTloop
@printQUESTlineLabel
	N: @#<arg1>
	GOTO @printQUESTloop
@printQUESTstdOneArg
	N: #<arg0> #<arg1>
	GOTO @printQUESTloop
@printQUESTcommaArgs
	N: #<arg0> #<arg1>, "#<arg2>"
	GOTO @printQUESTloop
@printQUESTthreeCommaArgs
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>
	GOTO @printQUESTloop
@printQUESTfourCommaArgs
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>
	GOTO @printQUESTloop
@printQUESTmultiArg		
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>, #<arg9>
	GOTO @printQUESTloop
@printQUESTspecialCase
	COMPARE #<currAction>, "01"
	IF= @printQUESTspecialCaseActor
	COMPARE #<currAction>, "04"
	IF= @printQUESTspecialCaseAsk
	COMPARE #<currAction>, "68"
	IF= @printQUESTspecialCaseDialog
	COMPARE #<currAction>, "33"
	IF= @printQUESTspecialCaseIf
	COMPARE #<currAction>, "36"
	IF= @printQUESTspecialCaseMenu
	COMPARE #<currAction>, "72"
	IF= @printQUESTspecialCaseNth_Token
	END
@printQUESTspecialCaseActor
	N: #<arg0> #<arg1>, "#<arg2>", #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>
	GOTO @printQUESTloop
@printQUESTspecialCaseAsk
	N: #<arg0> #<arg1> #<arg2>
	GOTO @printQUESTloop
@printQUESTspecialCaseDialog
	N: #<arg1>: #<arg2>
	GOTO @printQUESTloop
@printQUESTspecialCaseIf
	N: #<arg0> #<arg1> #<arg2>
	GOTO @printQUESTloop
@printQUESTspecialCaseMenu
	GOTO @printQUESTspecialCaseMenu-#<numArgs>
	END
@printQUESTspecialCaseMenu-3
	N: #<arg0> "#<arg1>=@#<arg2>"
	GOTO @printQUESTloop
@printQUESTspecialCaseMenu-5
	N: #<arg0> "#<arg1>=@#<arg2>","#<arg3>=@#<arg4>"
	GOTO @printQUESTloop
@printQUESTspecialCaseMenu-7
	N: #<arg0> "#<arg1>=@#<arg2>","#<arg3>=@#<arg4>","#<arg5>=@#<arg5>"
	GOTO @printQUESTloop
@printQUESTspecialCaseMenu-9
	N: #<arg0> "#<arg1>=@#<arg2>","#<arg3>=@#<arg4>","#<arg5>=@#<arg6>","#<arg7>=@#<arg8>"
	GOTO @printQUESTloop
@printQUESTspecialCaseNth_Token
	N: #<arg0> #<arg1>, #<arg2>, "#<arg3>", "#<arg4>", #<arg5>
	GOTO @printQUESTloop
@printQUESTvararg
	GOTO @printQUESTvararg-#<numArgs>
	END
@printQUESTvararg-2
	N: #<arg0> #<arg1>
	GOTO @printQUESTloop
@printQUESTvararg-3
	N: #<arg0> #<arg1>, #<arg2>
	GOTO @printQUESTloop
@printQUESTvararg-4
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>
	GOTO @printQUESTloop
@printQUESTvararg-5
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>
	GOTO @printQUESTloop
@printQUESTvararg-6
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>
	GOTO @printQUESTloop
@printQUESTvararg-7
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>
	GOTO @printQUESTloop
@printQUESTvararg-8
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>
	GOTO @printQUESTloop
@printQUESTvararg-9
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>
	GOTO @printQUESTloop
@printQUESTvararg-10
	N: #<arg0> #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>, #<arg9>
	GOTO @printQUESTloop


@printQUESTend
	N: <End Virtual Scene Output. Label: "*#<currlabel>">
	RETURN

;@lbmaparray scenenum, returnarray; RETURN returnarray
@lbmaparray 
	SET num.devTableId, 91
	SET str.devTableRowId, LBVS#<arg0>
	SET #<arg1>, 0
@lbmaparrayloop
	ADD #<arg1>, 1
	SET read, str.devTableCOL*#<arg1>
	STRCMP *#<read>, x
	IF= @lbmaparrayend
	COMPARE *#<arg1>, 32
	IF> @lbmaparrayend
	SET #<arg1>-*#<arg1>, *#<read>
	GOTO @lbmaparrayloop
@lbmaparrayend
	SUB #<arg1>, 1
	RETURN #<arg1>
	END

;@lbmaparray scenenum, mapnum, returnarray; RETURN returnarray
@lblinkarray 
	SET num.devTableId, 91
	SET str.devTableRowId, #<arg0>-#<arg1>
	SET #<arg2>, 0
@lblinkarrayloop
	ADD #<arg2>, 1
	SET read, str.devTableCOL*#<arg2>
	STRCMP *#<read>, x
	IF= @lblinkarrayend
	COMPARE *#<arg2>, 32
	IF> @lblinkarrayend
	SET #<arg2>-*#<arg2>, *#<read>
	GOTO @lblinkarrayloop
@lblinkarrayend
	SUB #<arg2>, 1
	RETURN #<arg2>

;@adddigits string, numzeroes; RETURN string
@adddigits
	COMPARE #<arg1>, "1"
	IF> @adddigitsloop
	SET arg0, "#<adddigits>"
	SET arg1, "#<numdigits>"
@adddigitsloop
		SET_LEN templen, "#<arg0>"
		COMPARE #<templen>, "#<arg1>"
		IF= @adddigitsend
		SET arg0, "0#<arg0>"
	GOTO @adddigitsloop
	END
@adddigitsend
	RETURN #<temp>
	END
	
	
@vslen
	SET arg, "#<arg0>"
	SET_LEN arglen, "#<arg0>"
	CALL @adddigits #<arglen>, #<arg1>
	RETURN #<arg0>#<arg>
	END
	
	
;@vspack
END
	SET argcount, "#<numArgs>"
	SUB argcount, "1"
	SET argsgot, "0"
	SET argsdone, "0"
	SET num.devTableId, 90
	SET str.devTableRowId, "#<arg0>"
	SET vsact, "#<str.devtableCOL1>"
	STRSTR "-11-29-", "-#<vsact>-"
	IF> @vspackreturn
	SET vsarg, ""
;@vspackgetloop
		ADD argsgot, "1"
		PUSH arg#<argsgot>
		POP vsarg#<argsgot>
		COMPARE #<argsgot>, #<argcount>
		IF< @vspackgetloop
;@vspackloop
		ADD argsdone, "1"
		PUSH vsarg#<argsdone>
		POP vsargnew
		CALL @vslen #<vsargnew>, 3
		SET vsarg, "#<vsarg>#<arg0>"
		COMPARE #<argsdone>, #<argcount>
		IF< @vspackloop
	COMPARE #<argcount>, "1"
	IF= @vspackreturnargs
	CALL @vslen #<vsarg>, 3
	RETURN #<vsact>#<arg0>
;@vspackreturnargs
	RETURN #<vsact>#<vsarg>
;@vspackreturn
	RETURN #<vsact>
	END
	
@vspack
	SET num.devTableId, 90
	SET str.devTableRowId, "#<arg0>"
	SET string, "#<str.devtableCOL1>"
	STRSTR "-11-27-", "-#<string>-"
	IF> @vspackreturn
	SET num, 0
	SUB numArgs, 1
@vspackloop
		ADD num, "1"
		SET name, "arg#<num>"
		SET string, "#<string>&*#<name>"
		COMPARE #<num>, #<numArgs>
		IF< @vspackloop
@vspackreturn
	RETURN #<string>


	
;@vsunpack
END
	SET string, "#<arg0>"
	SET_SUBSTR commandnum, 0, 2, #<string>
	SET stringcut, 2
	CALL @vsrevnamelookup #<commandnum>
	SET argcount, #<arg1>
	COMPARE #<argcount>, 1
	IF= @vsunpackskipstrcut
	ADD stringcut, 3
;@vsunpackskipstrcut
	SET_LEN stringlen, "#<string>"
	SUB stringlen, "#<stringcut>"
	SET_SUBSTR string, #<stringcut>, #<stringlen>, #<string>
	CALL @vsrevnamelookup #<commandnum>
	SET string0, "#<arg0>"
	STRSTR "-GOTO EXIT-END-", "-#<string0>-"
	IF> @vsunpackdone
	SET currarg, "0"
;@vsunpackloop
		ADD currarg, "1"
		SET_SUBSTR arglen, 0, 3, #<string>
		SET_SUBSTR arg#<currarg>, 3, #<arglen>, #<string>
		ADD arglen, "3"
		SET_LEN stringlen, "#<string>"
		SUB stringlen, "#<arglen>"
		SET_SUBSTR string, #<arglen>, #<stringlen>, #<string>
		COMPARE #<stringlen>, "0"
		IF> @vsunpackloop
;@vsunpackdone
	RETURN #<string0>, #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>, #<arg9>
	END


@vsunpack
	SET string, #<arg0>
	NTH_TOKEN read, 0, #<string>, "&"
	CALL @vsrevnamelookup #<read>
	SET currtoken, 0
@vsunpackloop
		ADD currtoken, 1
		NTH_TOKEN read, #<currtoken>, #<string>, "&"
		STRCMP #<read>, ""
		IF= @vsunpackdone
		SET arg#<currtoken>, #<read>
		COMPARE #<currtoken>, "9"
		IF< @vsunpackloop
@vsunpackdone
	RETURN #<arg0>, #<arg1>, #<arg2>, #<arg3>, #<arg4>, #<arg5>, #<arg6>, #<arg7>, #<arg8>, #<arg9>
	END
	
	
@vsrevlookup
	SET num.devTableId, 90
	SET str.devTableRowId, #<arg0>
	RETURN #<str.devTableCOL4>
	END
	
	
@vsrevnamelookup
	SET num.devTableId, 90
	SET str.devTableRowId, #<arg0>
	SET str.devTableRowId, #<str.devTableCOL4>
	RETURN #<str.devTableCOL5>, #<str.devTableCOL7>
	END

;end of vs functions
@vsafter
