Basically, I create a temp subset with all my elements in it....then I run this code to create a final subset with the elements in Alphabetic order. Actually, it only groups the first letter...but that's where you guys come in.
I think this could really help a lot of people if we can make it work for entire element names. Line 22 converts the first letter of the source subset job and the destination subset job into ASCII value and compare to determine if it's bigger or smaller. That if smaller, it inserts it in the destination subset in that spot...if bigger, it loops around and checks the next job in the destination subset. It continues this until it finds a job with a higher first letter.
I think what it needs to do next is check the second letter and if bigger...move on to the next job and start over with letter 1. It should cycle through every letter in the 'tJob' to put it in the exact right spot before moving on to the next job in the temp subset.
Code: Select all
jDim = 'Job Dimension';
tSubset = 'Temp Job Subset';
sSubset = 'Sorted Job Subset';
IF (SubsetExists( jDim, sSubset )=1);
SubsetDestroy( jDim, sSubset );
ENDIF;
SubsetCreate( jDim, sSubset );
tSubCount = SUBSETGETSIZE( jDim , tSubset);
tIndex = 1;
While ( tIndex <= tSubCount );
vJob = SUBSETGETELEMENTNAME( jDim, tSubset, tIndex );
sSubCount = SUBSETGETSIZE( jDim, sSubset );
IF ( sSubCount = 0);
SUBSETELEMENTINSERT( jDim, sSubset, tJob, 1 );
ELSE;
sIndex = 1;
While ( sIndex <= sSubCount );
sJob = SUBSETGETELEMENTNAME( jDim, sSubset, sIndex );
IF ( CODE ( tJob, 1 ) < CODE ( sJob, 1 ) );
SUBSETELEMENTINSERT( jDim, sSubset, tJob, sIndex );
sIndex = sSubCount + 1;
ELSE;
IF ( sIndex = sSubCount );
SUBSETELEMENTINSERT( jDim, sSubset, tJob, sIndex + 1 );
sIndex = sSubCount + 1;
ELSE;
sIndex = sIndex + 1;
ENDIF;
ENDIF;
END;
ENDIF;
tIndex = tIndex + 1;
END;