Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;-------------------------------------------------------------------------------- ;puts a pointer in the registry to an array to be used to store global variables ;returns the specified array ;ArrayName is the name of the array ;VarList is a pipe delimited list of the global variable names to be stored in the array ;-------------------------------------------------------------------------------- ;******************************************************************************** #DEFINESUBROUTINE REGISTERGLOBALARRAY(ArrayName,VarList) ;******************************************************************************** %ArrayName% = ARRDIMENSION(ITEMCOUNT(VarList,"|") + 1) ;array holding vars %ArrayName%[0] = VarList RETURN ENVIRONSET(ArrayName,&%ArrayName%) #ENDSUBROUTINE ;-------------------------------------------------------------------------------- ;returns the value of a global variable stored in a registered global array ;ArrayName is the name of the array ;Var is the name of the var ;-------------------------------------------------------------------------------- ;*************************************************************************** #DEFINEFUNCTION GETGV(ArrayName,Var) ;*************************************************************************** Pointer = ENVIRONMENT(ArrayName) RETURN *Pointer[ITEMLOCATE(Var,*Pointer[0],"|")] #ENDFUNCTION ;-------------------------------------------------------------------------------- ;sets the value of a global variable stored in a registered global array ;ArrayName is the name of the array ;Var is the name of the var ;value is the value to which the global variable should be set ;-------------------------------------------------------------------------------- ;*************************************************************************** #DEFINEFUNCTION SETGV(ArrayName,Var,Value) ;*************************************************************************** Pointer = ENVIRONMENT(ArrayName) *Pointer[ITEMLOCATE(Var,*Pointer[0],"|")] = Value RETURN #ENDFUNCTION ;demo REGISTERGLOBALARRAY("GlobalArray","Title|Message") ;create a global variable array, call it Global Array SETGV("GlobalArray","Title","This is the old title") ;set some values SETGV("GlobalArray","Message","This is the old message") MESSAGE(GETGV("GlobalArray","Title"),GETGV("GlobalArray","Message")) ;the result SETGV("GlobalArray","Title","This is the new title") ;change some values SETGV("GlobalArray","Message","This is the new message") MESSAGE(GETGV("GlobalArray","Title"),GETGV("GlobalArray","Message")) ;the result
Article ID: W17223
File Created: 2007:07:03:14:28:54
Last Updated: 2007:07:03:14:28:54