Contributed by: Carsten Müller
Using a folders container in Vispro/Rexx you might have no clue how to get the full path of the selected item in the container. Using VPGetItemValue you only get "path" from "c:\this\is\my\path" when you select "path" in the folders tree container. This snippet helps you to get the full qualified path name.
Note: This code snippet expects a variable "foldername" which stores the initial folder you use when initializing the container. The full qualified complete path of the selected item will be stored in the variable "pathname" by the end of this code snippet.
/* GET FULL PATH IN FOLDERS CONTAINERS */
/* BY CARSTEN MUELLER CM@WARPHOUSE.DE */
/* FOLDER NAME OF THE SHOWN FOLDER IS STORED IN VARIABLE foldername */
abort=""
/* GET INDEX AND VALUE OF SELECTED ITEM */
/* Get index of first selected item 1000 Container */
index=VpGetIndex(window,1000,'SELECTED',0)
/* Get item value at index 1000 Container */
value=VpGetItemValue(window,1000,index)
/* LOOK FOR PARENT ITEMS, IF THEY EXIST, GRAB THEIR VALUES */
do i=1 while abort<>"abort"
/* GET INDEX OF NEXT HIGHER PARENT ITEM */
/* Get index of parent item 1000 Container */
index=VpGetIndex(window,1000,'PARENT',index)
/* IF THIS NEXT HIGHER PARENT ITEM EXISTS, GRAB ITS VALUE */
/* IF IT NOT EXISTS, ABORT THE LOOP */
if index<>0 then do
/* Get item value at index 1000 Container */
value2=VpGetItemValue(window,1000,index)
/* ADD THE PARENT VALUE TO THE PATH VALUE */
value=value2||"\"||value
end
else do
abort="abort"
end
end
/* NOW WE NEED TO ADD THE FOLDER NAME TO THE WHOLE PATH VALUE */
pathname=foldername||value||"\"