/*------------------------------------------------------------------------- /* Environmental Systems Research Institute /*------------------------------------------------------------------------- /* Program: GETGRID.AML /* Purpose: Tool for browsing the file system to select a grid. /* /*------------------------------------------------------------------------- /* Usage: getgrid INIT {wildcard} {'position'} {'stripe'} /* Usage: getgrid /* /* Arguments: routine - name of the routine to be called. /* /* varname - name of the variable to receive the value returned /* from the menu - used with the INIT routine /* wildcard - the string (filter) for listing file names - /* defaults to '*' /* position - (quoted string) opening menu position. /* stripe - (quoted string) menu stripe displayed. /* /* Globals: /*------------------------------------------------------------------------- /* Calls: /*------------------------------------------------------------------------- /* Notes: /*------------------------------------------------------------------------- /* Input: /* Output: /*------------------------------------------------------------------------- /* History: Matt McGrath - 02/06/92 - Original coding /* bernie szukalski - 08/20/92 - modified getcover.aml to create /* getgrid.aml /* Matt McGrath - 11/21/92 - Added ability to save previous path /*========================================================================= /* &args routine varname wildcard position stripe &severity &error &routine bailout /* Check arguments &if [NULL %routine%] &then &call usage /* &call %routine% /* &return /*------------------- &routine USAGE /*------------------- /* &type Usage: GETGRID INIT {wildcard} {'''position'''} {'''stripe'''} &type Usage: GETGRID &return &inform /*------------------- &routine INIT /*------------------- /* Display the menu /* /* Set the name of the variable to receive the value set in the menu &if [NULL %varname%] &then &call usage &set .getgrid$varname = %varname% /* Initialize other variables /* string for listing files (directories) &set .getgrid$pathstring = '/*' /* /* Current directory /* Set path to previous one if this tool has already been used &if not [VARIABLE .arctools$get_savepath] &then &set .arctools$get_savepath &if [NULL %.arctools$get_savepath%] &then &set .getgrid$curdir = [SHOW &workspace] &else &set .getgrid$curdir = %.arctools$get_savepath% /* /* Subdirectories in the current directory &set .getgrid$subdir = %.getgrid$curdir% /* Pathname for defining scrolling list of files (coverages and directories) &set .getgrid$fileloc = %.getgrid$curdir%[UNQUOTE %.getgrid$pathstring%] /* Wildcard for listing files (list only files containing the wildcard) &if [NULL %wildcard%] &then &set wildcard = * &if [QUOTE %wildcard%] = '#' &then &set wildcard = * /* &if [NULL %position%] or %position%_ = #_ &then &set position = &cc &screen &cc &if [NULL %stripe%] or %stripe%_ = #_ &then &set stripe = 'Select a Grid' &if [SHOW &thread &exists tool$getgrid] &then &thread &delete tool$getgrid &thread &create tool$getgrid ~ &menu getgrid.menu ~ &position [UNQUOTE %position%] ~ &stripe [QUOTE [UNQUOTE %stripe%]] ~ &pinaction '&run getgrid cancel' /* /* Make this menu modal &run modal open tool$getgrid /* &return /*------------------- &routine CURDIR /*------------------- /* Change the current directory to the specified directory and update /* the list of subdirectories and coverages &if [NULL %.getgrid$curdir%] &then &do &set .getgrid$curdir = [DIR %.getgrid$fileloc%] &return &end /* /* Expand possible environment variables &set .getgrid$curdir = [PATHNAME [EXTRACT 1 %.getgrid$curdir%]] /* &if not [EXISTS %.getgrid$curdir% -DIR] &then &do &set temp = [DIR %.getgrid$fileloc%] &set .getgrid$message = Directory %.getgrid$curdir% does not exist &set .getgrid$curdir = %temp% &end &set .getgrid$fileloc = %.getgrid$curdir%[UNQUOTE %.getgrid$pathstring%] /* &return /*------------------- &routine SUBDIR /*------------------- /* Change the current directory to the specified subdirectory /* &set .getgrid$curdir = %.getgrid$subdir% &set .getgrid$fileloc = %.getgrid$subdir%[UNQUOTE %.getgrid$pathstring%] &return /*------------------- &routine UP /*------------------- /* Move up one directory. &set temp = [DIR %.getgrid$fileloc%] &set temp = [DIR %temp%] &set .getgrid$curdir = %temp% &if [QUOTE %temp%] = '/' &then &set temp &set .getgrid$fileloc = %temp%[UNQUOTE %.getgrid$pathstring%] &set .getgrid$message /* &return /*------------------- &routine OK /*------------------- /* Quit from menu, cleanup /* &set [VALUE .getgrid$varname] = %.getgrid$grid% /* Save the path for future use of this tool &set .arctools$get_savepath = %.getgrid$curdir% &call exit /* &return /*------------------- &routine CANCEL /*------------------- /* Set values to null to indicate to calling program that nothing was /* selected &set [VALUE .getgrid$varname] &call exit /* &return /*------------------- &routine EXIT /*------------------- /* Quit from menu, cleanup /* &dv .getgrid$* /* /* Close the modal menu and re-establish thread environment &run modal close tool$getgrid /* &return /*------------------- &routine BAILOUT /*------------------- /* &severity &error &ignore &severity &warning &ignore /*&call exit &return &warning An error has occurred in routine: %routine% (GETGRID.AML) /*----------------- &routine SAFETY_NET /*----------------- &return