CollectWords.gc

G4C
 
WINBIG 0 -10 600 360 CollectWords.gc
 
WINTYPE 11110001
 
xONLOAD
 Gosub #this Default
 
xONRELOAD
 Gosub #this Default
 
xONCLOSE
 ;GuiQuit #this
 
xROUTINE Default
 Bufferl = $$G4C.BUFFER ; bytes a variable can store. // and /* */ can not be used for commenting ";" are not needed 
								; if not followed by a comment
 EzReq $$G4C.BUFFER OK|stop var ; a requester, you can test on $var the value of 'var'
								;  
 Set Buffer 4096 			; not really needed was in earlier version where 'paragraphs' were parsed
 GuiOpen #this
 
 
 
xBUTTON 0 0 60 17 "_Load" ; <<Load>> ; the visually underscored L makes the L key a shortcut key
	GadHelp "Select files to analyse" ; help string appears on the screenbar, with xONTEXT you have more possibilities
 ReqFile 100 10 500 600 'Select the files to analyse ' Multi .WordFiles BareEd:
 RepVar .WordFiles " " "\n" CS 	; .WordFiles is an environmental variable (all variables beginning with a '.' are
 LVUse #this 1 						; 1 is the 'Gadget identifier' (GodId of the listview you select  
 LVClear
 LVUse #this 2							; #this refers to this gui. If another gui4cli is loaded, you could refter to it
											; as 'LVUse MyOtherGui 3 ' 
											; and use the same commands to manipulate that listview
 LVClear
 LVUse #this 3							
 LVChange env:.WordFiles 			; now we load the file corresponding to the environmental variable in a listview
 LVMulti ALL  							; highlight all lines
 LVClip CUT SELECTED ADD #this 2 ; powerfull & versatile command: cut all the highlighted lines & copy to Listview 2
 
xROUTINE SelectWords File_ 
 LVUse #this 3
 LVChange $File_						; load  into the listview 3
 LVRep "." "\n" CS					; replaces all occurences in the file loaded in listview. 
                   					; reduce the length of lines to parse (long paragraphs)
 LVRep ";" " " CS
 
 LVRep ":" " " CS						; not all are really needed ParseVar doe a goedd jog of parsing a 'normal' phrase
 LVRep "(" " " CS
 LVRep ")" " " CS
 LVRep "'" " " CS
 LVRep '"' " " CS
 LVRep '?' " " CS
 LVRep '!' " " CS
 LVRep ',' " " CS
 LVSave env:.Temp ; to make the changes of the \n replacements effective
 LVChange env:.Temp
 
 Delete env:.Temp
 LVGo first
 WHILE $$LV.LINE > ""
	IF $LVVar3 > " " ; was > "" 
 		ParseVar LVVar3
TextFile ram:t/NotNeededProbably ; using TextFile and ### allows you to comment out continuous poece of code
 IF $$LV.LINE = 0						; The text will be saved as ram:t/NotNeededProbably
	EzReq $LVVar3 ok|stop var		; Its prime use is of course to have data or txt (eg help)  available 
	.LVVar3 = $LVVar3					; that you can use or manipulate
 ENDIF
###
		tot_ = $$parse.total
		IF $tot_ > 0
			i = 0
			LVUse #this 1
			WHILE $i < $tot_
				LVAdd $$parse.$i
				++i
			ENDWHILE
		ENDIF
	ENDIF
	LVUse #this 3
 	LVGo next
	; say $$LV.LINE\n
 ENDWHILE
 
 
xBUTTON 60 0 60 17 "Select" ; <<Select>>  
	GadHelp "Select Words in 'loaded' files"
 Gosub #this SelectAllWords
 
xROUTINE SelectAllWords				; using subroutines instead of attaching a command sequence directly to a gadget 
											; has a major advantage: you can do a "Gosub "MyOtherGui  $Arg1 $Arg2  $Arg3  " directly
											; Since routines are 'arexx capable' you can address those subroutines 
											; from a non Gui4Cli application
 SetGad #this 1/3 HIDE				; This 'hides' the listviews and speeds up execution seriously
											; You have the same effect if the listviews used for intermediate results are 'drawn'
											; out of the window borders;
											; 
 LVUse #this 2
 LVGo first
 WHILE $$LV.LINE > ""
	Gosub #this SelectWords $LVVar2
	LVUse #this 2
	LVGo next
 ENDWHILE
 SetGad #this 1/3 SHOW
 LVUse #this 1
 LVMove 0
 
xBUTTON 120 0 60 17 "Sort" ; <<Sort>> 
 LVUse #this 1
 LVSort ASC
 
xBUTTON 180 0 60 17 "DelDbles" ; <<DelDbles>> 
	GadHelp "delete doubles"
 SetGad #this 1/3 HIDE
 LVUse #this 1
 LVMulti all
 LVClip CUT Selected PASTE #this 3
 LVUse #this 3
 LVGo first
 IF $LVVar3 > ""
	LastWord = $LVVar3
	LVUse #this 1
	LVAdd $LVVar3
	LVUse #this 3
 ELSE 
	stop ; empty LV
 ENDIF
 LVGo next
 WHILE $$LV.LINE > ""
	IF $LVVar3 == $LastWord ; case insensitive 
		;
	ELSE
		LVUse #this 1
		LVAdd $LVVar3
		LastWord = $LVVar3
		LVUse #this 3
	ENDIF
	LVGo next
 ENDWHILE
 SetGad #this 1/3 SHOW
 LVUse #this 3
 LVClear
 LVUse #this 1
 LVMove 0
 
 
xBUTTON 240 0 60 17 "" ; <<>> 
 
 
xBUTTON 300 0 60 17 "" ; <<>> 
 
xBUTTON 360 0 60 17 "" ; <<>> 
 
xBUTTON 420 0 60 17 "?" ; <<>>
 EzReq $.SelWd_Goal ok var
 
 
xBUTTON 480 0 60 17 "Save" ; <<Save>>
	GadHelp "Save to clipboard"
 LVUse #this 1
 LVSave clips:0
 
 
xBUTTON 540 0 60 17 "Quit" ; <<Quit>>
 Set Buffers $Bufferl								; reset to initial value
 Delete ram:t/NotNeededProbably					; 
 GuiQuit #this
 
 
 
xLISTVIEW 0 17 600 120  '' LVVar1 "" 30 Multi ; Listviews are the most powerfull Gui4Cli gadgets
															 ; you have differend kinds DIR, MULTI SHOW, TEXT
															 ; and you can using the command LVMODE MULTI
															 ; change the 'mode' the listview is working in. 
	GadId 1 
	GadHelp LV1
 
xLISTVIEW 0 137 600 120  '' LVVar2 "" 30 Multi
	GadID 2
	GadHelp LV2
 
xLISTVIEW 0 257 600 120  '' LVVar3 "" 30 Multi
	GadID 3
	GadHelp LV3 
 
 
TEXTFILE env:.SelWd_Goal
 This gui allows you to select a number of ascii text files and 
 produce an alphabetic list of the words in those files.
 You should use the buttons from left to right.
 The list can be saved to clipboard.
 Use Ctl_R to reset the gui for a new session
###