#!/bin/sh
 
 # g_code
 # ======

 # This file is part of Gerolf Markup Shredder,
 # written by G. D. Brettschneider (1999-2006).
 
 GMSdateG_CODE=20060927
 
 # Prologue: ##################################################################
 
 # Not running:
 
 if [ "$GMS_SHELL" = "" ]; then
   echo "This is Gerolf Markup Shredder (g_code)."
   exit
 fi 
 
 # Debug: ---------------------------------------------------------------------
   
 if [ "$GMS_DEBUG" = "X" -o "$GMS_DEBUG" = "Y" ]; then
   source "$GMS_SHELL/l_banner" -debug g_code $1 $2 $3 $4
 elif  [ "$GMS_DEBUG" = "Z" ]; then
   echo " g_code ($1) ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9)" >> "$Z"
 fi 
 
 # Chapters: ##################################################################
 
 # Not defined:
 
 if [ "$1" = "" ]; then source "$GMS_SHELL/l_banner" -no_action g_code
   
 # Resize: --------------------------------------------------------------------
 
 elif [ $1 = -resize ]; then
   export REPLY_OFFSET=3
   export REPLY_SIZE=72
   export REPLY_ITEMS=1
   
 # Remove: --------------------------------------------------------------------
 
 elif [ $1 = -remove ]; then
   source "$GMS_SHELL/g_code" -resize called_by g_code -remove
   source "$GMS_SHELL/l_rain" -remove  called_by g_code -remove # sic! =>l_code
   source "$GMS_SHELL/l_banner" -lower -folder called_by g_code -remove
#  source "$GMS_SHELL/g_menu" -build called_by g_code -remove
   
 # Build: ---------------------------------------------------------------------
 
 elif [ $1 = -cp_up_build -o $1 = -cp_lo_build ]; then 
   BACKUP=$1
   source "$GMS_SHELL/g_select" -resize called_by g_code -build
   source "$GMS_SHELL/l_box" -t11_remove called_by g_code -build
   source "$GMS_SHELL/g_menu" -resize called_by g_code -build
   source "$GMS_SHELL/l_box" -remove called_by g_code -build 
   source "$GMS_SHELL/g_code" -resize called_by g_code -build 
   if [ $BACKUP = -cp_up_build ]; then
     source "$GMS_SHELL/l_code" -cp_up called_by g_code -build
     source "$GMS_SHELL/l_banner" -lower -cp_up called_by g_code -build
   else
     source "$GMS_SHELL/l_code" -cp_lo
     source "$GMS_SHELL/l_banner" -lower -cp_lo called_by g_code -build
   fi
   BACKUP=
   source "$GMS_SHELL/g_code" -remove called_by g_code -build 
   if [ -f "$REPLY_TEMP" ]; then rm "$REPLY_TEMP"; fi     
   # Build menu: 
   export GMS_COLD=S
   export GMS_HOT=S
   source "$GMS_SHELL/g_menu" -build called_by g_code -build
   
 # Not found: -----------------------------------------------------------------
 
 else
   source "$GMS_SHELL/l_banner" -no_action g_code $1   
 fi
