;+------------------------------------------------------------- ; NAME: ; addTreeToTag ; PURPOSE: ; return tags with trees merged in ; CATEGORY: ; MDSplus, SCOPE ; CALLING SEQUENCE: ; names = addTreeToTag( tags, trees ) ; INPUTS: ; tags - array of tags, e.g., '\ip1' (if tree already there, will not change) ; trees - array of trees (same dimension as tags) ; RETURNED: ; names - tag names with tree in them, e.g., '\engineering::ip1' ; KEYWORDS: ; COMMON BLOCKS: ; none ; EXAMPLE: ; IDL> print, addTreeToTag( ['\ip1+\ip2'], ['engineering'] ) ; \engineering::ip1+\engineering::ip2 ; IDL> print, addTreeToTag( ['\engineering::ip1.blah+\ip2'], ['engineering'] ) ; \engineering::ip1.blah+\engineering::ip2 ; LIMITATIONS: ; MODIFICATION HISTORY: ; 30-Apr-01 Written by Bill Davis ;-------------------------------------------------------------- FUNCTION addTreeToTag, tags, trees outTags = tags for i=0, n_elements( tags )-1 do begin tag = tags[i] ipos = 0 found = 1 newTag = '' while( found ) do begin slashPos = STRPOS( STRMID(tag, ipos, 1000 ), '\' ) IF slashPos[0] EQ -1 THEN BEGIN found = 0 newTag = newTag + tag ENDIF ELSE BEGIN newTag = newTag + STRMID( tag, ipos, slashPos-ipos+1 ) tag = STRMID( tag, slashPos+1, 1000 ) nextNonPos = nonVarPos( tag ) if nextNonPos[0] EQ -1 then nextNonPos = STRLEN( tag ) -1 nextCCPos = STRPOS( STRMID(tag, 0, nextNonPos[0]), '::' ) IF nextCCPos[0] LT 0 THEN BEGIN newTag = newTag + trees[i] + '::' ENDIF ENDELSE endwhile outTags[i] = newTag endfor return, outTags end