[r6]: / trunk / json / json-pac / Functions / SPLIT_VARNAME / svnobj  Maximize  Restore  History

Download this file

5 lines (5 with data), 7.3 kB

Gx_li!0Еj№o0FВРA░System.StringL{6f9dac99-8de1-4efc-8465-68ac443b7d08}SpecialFuncL{0db3d7bb-cde0-4416-9a7b-ce49a0124323}NoneImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocument	L{f3878285-8e4f-490b-bb1b-9acbb7eb04db}
TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}Id
longTagText╥(*=======================================================================================================SPLIT_VARNAME()VAuthor: Tim Van Meppelen, Pro Electric Inc.(timv@proelectric.com&Date: June 26, 2018bsplit a string into an array at the '.' characterTO DO:h'a.b.c.d' becomes an array[1]=d, [2]=c, [3]=b, [4]=axmodified from https://forum.codesys.com/viewtopic.php?t=9889╘========================================================================================================*)Ю//Loop through string until there is no string left or array has hit its limits^WHILE (StrLenA(pstData:= ADR(StringIn)) > 0) DOJ	//Find location of first break point┬	iSplitLocation := StrFindA(pst1:= ADR(StringIn), pst2:= ADR(SPLIT_CHAR), uiSearchStart:= 1) - 1;	 О	//If there is no break point found then set location to size of string!<	IF (iSplitLocation = -1) THEN"Д		iSplitLocation := DINT_TO_INT(StrLenA(pstData:= ADR(StringIn)));#	END_IF$  %А	//Copy the part of the string that is needed for the parameter.&	StrMidA('0			pst:= ADR(StringIn), (R			uiInputBufferSize:= SIZEOF(StringIn), ):			iLength:= iSplitLocation, *$			iPosition:= 1, +D			pstResult:= ADR(sShortString), ,\			uiResultBufferSize:= SIZEOF(sShortString));-~	//Make sure string is not empty before using up an array spot..f	IF (StrLenA(pstData:= ADR(sShortString)) > 0) THEN/N		TempArray[ArraySize] := sShortString;0:		ArraySize := ArraySize + 1;1X	//Remove copied components from long string2╝	StrDeleteA(pby:= ADR(StringIn), iLength:= (iSplitLocation + LEN(SPLIT_CHAR)), iPosition:= 1);3К	//Check to see if more parameters can fit in array. If not exit loop4T	IF (ArraySize > GPL_JSON.MAX_LEVELS) THEN5		EXIT;6	END_IF 7END_WHILE84ArraySize:= ArraySize - 1;92FOR i:= 0 TO ArraySize DO:@//reverse the order of the array;d	VarNameArray[i+1].Name:= TempArray[ArraySize-i];	<END_FOR=4SPLIT_VARNAME:= ArraySize;>Interface?L{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}@<FUNCTION SPLIT_VARNAME : UINT;AVAR_INPUTBТ	VarNameArray:	REFERENCE TO ARRAY[1..GPL_JSON.MAX_LEVELS] OF JSONVARNAME;Ct	StringIn: 		STRING(GPL_JSON.MAX_VAR_NAME);	//input stringDEND_VAREVAR CONSTANTF@	SPLIT_CHAR : 	STRING(1):= '.';	GVARH.	ArraySize:			UINT:= 1;I8    sShortString : 		STRING;J4    iSplitLocation : 	INT;K	i:					UINT;Ll	TempArray:			ARRAY[1..GPL_JSON.MAX_LEVELS] OF STRING;M"UniqueIdGeneratorN94OPOULevelPL{8e575c5b-1d37-49c6-941b-5c0ec7874787}QStandardR ChildObjectGuidsS8System.Collections.ArrayListT,AddAttributeSubsequentUbool╨╨-╨╨	E
7╨╨
н┌╨-╨╨
н	┌╨-╨╨
н
┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н
┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н┌╨-╨╨
н ┌╨-╨╨
н!┌╨-╨╨
н"┌╨-╨╨
н#┌╨- ╨╨
н$┌╨-!╨╨
н%┌╨-"╨╨
н&┌╨-#╨╨
н'┌╨-$╨╨
н(┌╨-%╨╨
н)┌╨-&╨╨
н*┌╨-'╨╨
н+┌╨-(╨╨
н,┌╨-)╨╨
н-┌╨-*╨╨
н.┌╨-+╨╨
н/┌╨-,╨╨
н0┌╨-╨╨
н1┌╨--╨╨
н2┌╨-.╨╨
н3┌╨-/╨╨
н4┌╨-0╨╨
н5┌╨-#╨╨
н6┌╨-╨╨
н7┌╨-1╨╨
н8┌╨-2╨╨
н9┌╨-╨╨
н:┌╨-3╨╨
н;┌╨-4╨╨
н=┌╨-5╨╨
н>┌╨-6╨╨
нG┌╨-7╨╨
нR┌╨-╨╨
нS┌╨-8╨╨
нH┌╨-╨╨
нI┌╨-9╨╨
нJ┌╨-:╨╨
нK┌╨-;╨╨
н^┌╨-<╨╨
н\┌╨-╨╨
н]┌╨-=╨╨
н┌╨-╨>?╨	E
╨╨
н?┌╨-@╨╨
нY┌╨-A╨╨
нD┌╨-B╨╨
нB┌╨-C╨╨
н@┌╨-D╨╨
н[┌╨-╨╨
нW┌╨-E╨╨
нX┌╨-F╨╨
нU┌╨-D╨╨
н┌╨-╨╨
нZ┌╨-G╨╨
н┌╨-H╨╨
н┌╨-I╨╨
н┌╨-J╨╨
нQ┌╨-K╨╨
н┌╨-L╨╨
н┌╨-D╨╨
н┌╨-╨M-N╨OP-QRS╨TUн