WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ArrayRedim Sample

 Keywords: Arrinfo ArrayRedim Resize Array Dim

2010B and newer

;------------------------------------------------------------------------------------------------------------------------------------------
; Example script for a possible usage of array function "ArrayRedim".
;------------------------------------------------------------------------------------------------------------------------------------------
; Note:
; The array function "ArrInfo" is used in this example only to demonstrate,
; that an explicite counter variable is not necessarily needed.
; In real life the "ArrInfo" function calls should be replaced by integer counter variables,
; e. g. intFileCount and intArrIndex, which can provide the current index values too, by less cpu cycles.
;------------------------------------------------------------------------------------------------------------------------------------------
; (c)Detlev Dalitz.20100724.
;------------------------------------------------------------------------------------------------------------------------------------------

DirChange (DirScript ())

strMsgTitle = 'Search for files.'
strMsgText = ""
BoxOpen (strMsgTitle, strMsgText)
WinPlace (050, 100, 950, 600, "")
BoxDataTag (1, 1)

strFolderTemp = ShortCutDir ("Local Settings") : "\Temp\"
strFileOut = StrInsert (StrReplace (TimeYmdHms (), ":", ""), ".", "", 9) : ".List.txt"
strFileOut = strFolderTemp : strFileOut

; Search for files in the personal folder recursively.
strFolderSource = ShortCutDir ("Personal")
strFileMask = "*.jpg"
;strFileMask = "*.txt"
;strFileMask = "*.htm*"

AddExtender ("wwfaf44i.dll") ; File and Folder Finder.
;fafHidden = 1      ; Include hidden files.
;fafSystem = 2      ; Include system files.
;fafFolders = 4     ; Inspect  subfolder names also.
;fafFindFolders = 8 ; Only inspect subfolder names not file names.
fafRecurse = 16    ; Recurse through subfolders.
;fafNoPathInfo = 32 ; Do not return path information to files or folders found.
;fafNoRedirect = 64 ; Do not turn off file redirection for x64 windows.

; Start with an empty dim-1 array.
arrList = ArrDimension (0)

hdlFAF = fafOpen (strFolderSource, strFileMask, fafRecurse)
While @TRUE
   strFileFullName = fafFind (hdlFAF)
   If strFileFullName == "" Then Break

   ; Add one new element to the array and fill it with a value.
   ArrayRedim (arrList, ArrInfo (arrList, 1) + 1)
   arrList[ArrInfo (arrList, 1) - 1] = strFileFullName

   strMsgText = "Files found: " : ArrInfo (arrList, 1) : @LF : @LF : StrReplace (strFileFullName, "\", "\" : @LF)
   BoxText (strMsgText)
   BoxDataClear (1, 1)
EndWhile
fafClose (hdlFAF)

If ArrInfo (arrList, 1) > 0
   ArraySort (arrList)
   intBytesWritten = ArrayFilePut (strFileOut, arrList)
EndIf

strMsgText = "Files found: " : ArrInfo (arrList, 1) : @LF : @LF : "Ready."
BoxButtonDraw (1, 1, "&OK", "50,780,950,950")
BoxText (strMsgText)
While !BoxButtonStat (1, 1)
   TimeDelay (0.2)
EndWhile
BoxButtonKill (1, 1)

If FileExist (strFileOut) == 1 Then Run (strFileOut, "")

:CANCEL
Exit
;------------------------------------------------------------------------------------------------------------------------------------------

Article ID:   W17673
Filename:   ArrayRedim Sample.txt
File Created: 2011:02:23:12:08:00
Last Updated: 2011:02:23:12:08:00