/* $VER: OpenTemplate.rexx 1.0f (22.07.96) Copyright 1996 SoftLogik Publishing Corporation May not be distributed without SoftLogik Publishing Corporation's express written permission */ OPTIONS RESULTS ADDRESS 'PAGESTREAM' /* Make sure rexx support is opened */ IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30) /* Build the template list */ dPath="PageStream:Scripts/TemplateData" Files=showdir(dPath,file,'|') fLength=length(Files) /* Check for valid template data files. Only .data are listed */ nList=0 DO WHILE fLength>0 cLength=pos('|',Files) IF cLength=0 then DO cLength=FLength+1 fLength=0 END cFile=left(Files,cLength-1) eFile=right(cFile,cLength-lastpos('.',cFile)) IF eFile='.data' THEN DO cFile=left(cFile,cLength-6) nList=nList+1 List.nList=cFile END IF FLength~=0 THEN Files=right(Files,fLength-cLength) fLength=fLength-cLength END /* If there aren't any data files, alert the user and exit */ IF nList=0 THEN DO allocarexxrequester '"Open Template Alert"' 358 65 alerthandle=result addarexxgadget alerthandle EXIT 276 48 70 label "_Exit" cancelhandle=result addarexxgadget alerthandle TEXT 8 8 346 string '"There are no template data files in the"' addarexxgadget alerthandle TEXT 8 22 346 string '"PageStream:Scripts/TemplateData directory."' doarexxrequester alerthandle choice=result freearexxrequester alerthandle EXIT END /* Sort the list alphabetically */ DO tick = 1 to nList - 1 nexttick = tick + 1 IF List.tick > list.nexttick THEN DO store = List.nexttick List.nexttick = List.tick DO bubpos = tick-1 to 1 by -1 WHILE (store < list.bubpos) nexttick = bubpos + 1 List.nexttick = List.bubpos END bubpos bubpos = bubpos + 1 List.bubpos = store END END tick /* Allocate and fill the template list */ allocarexxlist tlisthandle=result i=1 DO WHILE i