#!/bin/sh
 
 # g_list
 # ======
 
 # This file is part of Gerolf Markup Shredder,
 # written by G. D. Brettschneider (1999-2006).
 
 GMSdateG_LIST=20060927
 
 # Prologue: ==================================================================
 
 # Not running:
 
 if [ "$GMS_SHELL" = "" ]; then
   echo "This is Gerolf Markup Shredder (g_list)."
   exit
 fi 
 
 # Debug: ---------------------------------------------------------------------
   
 if [ "$GMS_DEBUG" = "X" -o "$GMS_DEBUG" = "Y" ]; then
   source "$GMS_SHELL/l_banner" -debug g_list $1 $2 $3 $4
 elif  [ "$GMS_DEBUG" = "Z" ]; then
   echo " g_list ($1) ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9)" >> "$Z"
 fi 
 
 # Function: ------------------------------------------------------------------
 
 function g_list_handle_names {
   if [ $INDEX -gt $REPLY_LIST -a $INDEX -lt $[$REPLY_LIST+10] ]; then
     if [ $INDEX = $[$REPLY_LIST+1] ]; then
       export REPLY1="$f"; export GMS1="$str" 
     elif [ $INDEX = $[$REPLY_LIST+2] ]; then
       export REPLY2="$f"; export GMS2="$str" 
     elif [ $INDEX = $[$REPLY_LIST+3] ]; then
       export REPLY3="$f"; export GMS3="$str" 
     elif [ $INDEX = $[$REPLY_LIST+4] ]; then
       export REPLY4="$f"; export GMS4="$str" 
     elif [ $INDEX = $[$REPLY_LIST+5] ]; then
       export REPLY5="$f"; export GMS5="$str" 
     elif [ $INDEX = $[$REPLY_LIST+6] ]; then
       export REPLY6="$f"; export GMS6="$str" 
     elif [ $INDEX = $[$REPLY_LIST+7] ]; then
       export REPLY7="$f"; export GMS7="$str" 
     elif [ $INDEX = $[$REPLY_LIST+8] ]; then
       export REPLY8="$f"; export GMS8="$str" 
     elif [ $INDEX = $[$REPLY_LIST+9] ]; then
       export REPLY9="$f"; export GMS9="$str"; break
     fi
   fi; }
 
 # Chapters: ==================================================================
 
 # Not defined:
 
 if [ "$1" = "" ]; then source "$GMS_SHELL/l_banner" -no_action g_list
   
 # Clear: ---------------------------------------------------------------------
 
 elif [ $1 = -clear ]; then 
   # File names:
   export REPLY1=
   export REPLY2=
   export REPLY3=
   export REPLY4=
   export REPLY5=
   export REPLY6=
   export REPLY7=
   export REPLY8=
   export REPLY9=   
   # Folder marks [//]: 
   export GMS1=
   export GMS2=
   export GMS3=
   export GMS4=
   export GMS5=
   export GMS6=
   export GMS7=
   export GMS8=
   export GMS9=
   
 # Handle: --------------------------------------------------------------------
 
 elif [ $1 = -handle ]; then 
   INDEX=0
   for f in *; do #  Folder mark:
     if [ -d "$f" ]; then 
       str="[//]"; INDEX=$[$INDEX+1]
       g_list_handle_names
     fi    
   done
   for f in *; do
     if [ -f "$f" ]; then 
       str="    "; INDEX=$[$INDEX+1]
       g_list_handle_names
     fi
   done 
   INDEX=
   str=
 
 # Not found: -----------------------------------------------------------------
 
 else
   source "$GMS_SHELL/l_banner" -no_action g_list $1   
 fi
