;*sample for FINDFIRST and $-variables

;*****************************************************************************
;*                                                                           *
;* FindFirst.was                                                             *
;* Copyright (C) 1998 Symantec Corp							                             *
;* All rights reserved.                                                      *
;*                                                                           *
;* Short description of program...                                           *
;*                                                                           *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including     *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*****************************************************************************

;*****************************************************************************
;*   GLOBAL VARIABLES                                                        *
;*****************************************************************************
string FileTypes             ;file specification for searching
string FileExtension         ;Extension of the found file
string FileTitle             ;name of the file
string SizeOfFile            ;size of the file
string DateOfFile            ;date of the file
string TimeOfFile            ;time stamp of the file
string AttributesOfFile      ;attributes of the file

;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;* The Main procedure DisplayDialog to display the dialog box.  It also      *
;* initializes the WHEN statement for the events in dialog Box 0.
;*                                                                           *
;* Calls: Proc1, Proc2                                                       *
;* Modifies globals: Var1                                                    *
;*                                                                           *
;*****************************************************************************
proc main

   when dialog 0 call Handler0
   
   DisplayDialog ()
   
endproc



;*****************************************************************************
;*                                                                           *
;* DisplayDialog                                                             *
;* The procedure DisplayDialog displays the dialog box with the file         *
;* specification for the FINDFIRST and FINDNEXT commands.  It also displays  *
;* the results of the file that was found by these two commands.             *
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Main                                                           *
;* Modifies globals: Filetypes                                               *
;*                                                                           *
;*****************************************************************************
proc DisplayDialog
      
                   ;Create the dialog box.  This is a Style 71 box --
                   ;64 = suspend script while the dialog box is displayed
                   ; 4 = Modeless
                   ; 2 = Movable with caption
                   ; 1 = centered
	dialogbox 0 107 46 264 113 71 "FINDFIRST Command" 
	                ;The text explains what is to be entered into the edit
	                ;box.  In this case, it is to be something like "*.wax"
   	text 1 15 11 34 11 "FileSpec" left 
	   editbox 2 63 10 102 11 FileTypes 
	                ;The texts 3-8 will contain the contents of the system
	                ;variables that describe the file found with the
	                ;findfirst command.
   	text 3  22 36 92 11 FileTitle left
	   text 4  22 53 92 11 FileExtension left  
   	text 5  22 69 92 11 AttributesOfFile left 
	   text 6 155 36 92 11 TimeOfFile left
   	text 7 155 53 92 11 DateOfFile left 
	   text 8 155 69 92 11 SizeOfFile left 
	                ;Click on this button to do a FINDFIRST on the file
	                ;specs listed in the edit box.
   	pushbutton 24 17 86 54 13 "FindFirst" DEFAULT
   	             ;click this button to do a FINDNEXT on the same filespecs
	   pushbutton 25 97 86 54 13 "FindNext" 
	                ;click this button to exit the script
   	pushbutton 26 177 86 54 13 "Exit" CANCEL
	enddialog 

endproc


;*****************************************************************************
;*                                                                           *
;* Handler0                                                                  *
;* The procedure Handler0 precesses the events from Dialog Box 0. According  *
;* to which button was pushed, a file is located.  The information about this*
;* file is retrieved from the system variables and displayed in the dialog   *
;* box.                                                                      *
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Main                                                           *
;* Modifies globals: FileTitle, FileExtension, SizeOfFile, DateOfFile,       *
;*     TimeOfFile, AttributesOfFile                                          *
;*                                                                           *
;*****************************************************************************
proc Handler0
integer Event0               ;event in Dialog Box 0

                   ;Which event happened in Dialog Box 0?
	dlgevent 0 Event0
	      
	                ;make decisions based on the event
	switch Event0
	                ;Findfirst button
		case 24
	                ;Find the first file with the file specs contained
	                ;in FileTypes
			findfirst FileTypes
		             ;Format the system variables describing the first file
		             ;into the corresponding variables for the texts in the
		             ;dialog box.
			strfmt FileTitle "File Name is %s" $FNAME
			strfmt FileExtension "Extension is %s" $FEXT
			strfmt SizeOfFile "Size is %li bytes" $FSIZE
			strfmt DateOfFile "Date is %s" $FDATE
			strfmt TimeOfFile "Time is %s" $FTIME
			strfmt AttributesOfFIle "Attributes are %s" $FATTR
		             ;After the variables are formatted, then update the
		             ;texts in the dialog box.
			dlgupdate 0 3 8
		endcase
	                ;FindNext button
		case 25
	                ;Find the next file with the same file specs as the
	                ;last FINDFIRST command
			findnext 
		             ;Format the system variables describing the first file
		             ;into the corresponding variables for the texts in the
		             ;dialog box.
			strfmt FileTitle "File Name is %s" $FNAME
			strfmt FileExtension "Extension is %s" $FEXT
			strfmt SizeOfFile "Size is %li bytes" $FSIZE
			strfmt DateOfFile "Date is %s" $FDATE
			strfmt TimeOfFile "Time is %s" $FTIME
			strfmt AttributesOfFIle "Attributes are %s" $FATTR
		             ;After the variables are formatted, then update the
		             ;texts in the dialog box.
			dlgupdate 0 3 8
		endcase
	                ;exit button
		case 26
			exit
		endcase
	endswitch
endproc
	
