G4C

; A GUI for the PD Rewrap and StripHR programs.
; By G. Maddox 24 Sep 1996


WinBig -1 -1 350 109 "TextWrap 1.0"
WinSmall 200 0 240 -1
WinType 11110000
UseTopaz
NofontSense

; ------------------------ GRAPHICS -------------------------

BOX 0 0 0 0 IN BUTTON
BOX 4 2 342 45 OUT BUTTON
BOX 4 48 342 38 OUT BUTTON
BOX 4 87 342 20 OUT BUTTON

; ------------------------ GENERAL EVENTS -------------------

xOnLoad
setvar tw_flag 0
ifexists FILE c:ReWrap		; find out if the programs needed exist
  ifexists FILE c:StripHR	; & notify user if they don't
    setvar tw_flag 1
  endif
endif
if $tw_flag = 0
  ezreq 'This GUI needs files:\nc:ReWrap and c:StripHR\nto work correctly.' OK ""
endif
delvar tw_flag
SetVar tw_inf "No File Loaded."
SetVar wdth "75"
SetVar tab "5"
GuiOpen TextWrap.gc
Update TextWrap.gc 1 $wdth
Update TextWrap.gc 2 $tab
Update TextWrap.gc 3 $tw_inf

xOnClose
GuiQuit TextWrap.gc

; ------------------------ THE GADGETS ----------------------

xButton 15 10 60 12 "Open"
ReqFile -1 -1 300 -40 "Select File..." LOAD tw_src SYS:
Gosub TextWrap.gc split

xHSlider 95 54 200 11 "Columns:" wdth 35 140 75 "%1ld"
GadID 1

xHSlider 95 69 200 11 "   Tabs:" tab 0 8 5 "%1ld"
GadID 2

Text 80 10 250 13 $tw_inf 35 BOX
GadID 3

xTextIn 80 27 250 13 "Save As" tw_ouf "" 35
GadID 4
Gosub TextWrap.gc check

xButton 25 91 70 12 "Start"
If $tw_src != ""
   Joinfile $tw_path $tw_ouf tw_out
   CLI 'c:striphr >nil: $tw_src t:temp.txt'
   CLI 'c:rewrap >nil: -l$wdth -t$tab t:temp.txt $tw_out'
   Delete t:temp.txt
   EzReq "File Processed." "Okay" opt
   Stop
Else
   EzReq "Can't process that file -\ngive me one that exists!" "Whoops!" opt
   Stop
Endif

xButton 140 91 70 12 "Info"
EzReq "TextWrap 1.0\n\nBy G.Maddox 1996.\n\nWritten using the\nwonderful Gui4Cli\nprogram.\n" "Cool!" opt
Stop

xButton 255 91 70 12 "Quit"
GuiClose TextWrap.gc

; ------------------------ ROUTINES -------------------------

xRoutine split
Extract tw_src FILE tw_inf
Extract tw_inf UNQUOTE tw_inf
Extract tw_src PATH tw_path
Extract tw_path UNQUOTE tw_path
Setvar tw_ouf '$tw_inf'
Appvar tw_ouf ".rw"
Update TextWrap.gc 3 $tw_inf
Update TextWrap.gc 4 $tw_ouf
Return

xRoutine check
Cutvar tw_ouf COPY CHAR -3 tw_end
If $end != ".rw"
   Appvar tw_ouf ".rw"
   Delvar tw_end
   Update TextWrap.gc 4 $tw_ouf
Endif
Return




