none
Combining multiple arrays into one RRS feed

  • Question

  • I am sure this is probably really simple to do, but for some reason I just cannot figure it out.  

    I am creating an HTA that will be used to backup terminated employee's PC.  It will scan the drive for the specific file Types chosen and XCopy them up to the server.

    Originally I had the different file types writing into Strings and then just combining those strings.  I was deliminating the entries with a ;.  The issue I ran into is when combining them I have to have a ; in front of the first entry, the issue starts if someone only choose one file type.  Then it looks for any file with no extensions, which is a lot.  

    So then I thought I would just put them into their own arrays and then combine those arrays, but this just seems to be above my head.  I cannot wrap my mind around it.  

    Writing it in VBScript.  Here is the a snippet of the section I am working on.  Everything else in the script/HTA works fine. 

    Sub Extensions(strEndUserFolder)
    	
    	If Office.checked Then strOfficeExtensions = "doc;docx;docm;xls;xlt;xlm;xlsx;xlsm;ppt;pps;pptx;pptm;ppsx;ppsm;mdb;ldb;one;onetoc2"
    	If PDF.checked Then strPDFExtensions = "pdf"
    	If SRA.checked Then strSRAExtensions = "rws"
    	If Pictures.checked Then strPictureExtensions = "bmp;jpg;jpeg;gif;tiff;png"
    	If Videos.checked Then strVideoExtensions = "mp4;mov;mpeg;mpg;wmv;mov"
    	If Notes.checked Then strNotesExtensions = "id"
    	If CADUG.checked Then strCADUGExtensions = "dwg;dwt;dxf;dwf;dst;prt"
    	
    	arrOfficeExtensions = Split(strOfficeExtensions, ";")
    	arrPDFExtensions = Split(strPDFExtensions, ";")
    	arrSRAExtensions = Split(strSRAExtensions, ";")
    	arrPictureExtensions = Split(strPictureExtensions, ";")
    	arrVideoExtensions = Split(strVideoExtensions, ";")
    	arrNotesExtensions = Split(strNotesExtensions, ";")
    	arrCADUGExtensions = Split(strCADUGExtensions, ";")
    	
    	arrExtensions = 
    	
    	Call SetDrivetoScan(arrExtensions, strEndUserFolder)
    
    End Sub

    Friday, August 22, 2014 9:54 PM

Answers

  • Wow!  A hash table in VBScript would be a great extension.

    Sounds like a job for "ta-da!" ... Array Man!.

    Sub Extensions(strEndUserFolder)
    	
        ext=""
        If Office.checked Then ext=ext & "doc;docx;docm;xls;xlt;xlm;xlsx;xlsm;ppt;pps;pptx;pptm;ppsx;ppsm;mdb;ldb;one;onetoc2;"
        If PDF.checked Then ext = ext & "pdf;"
        If SRA.checked Then ext = ext & "rws;"
        If Pictures.checked Then ext = ext &  "bmp;jpg;jpeg;gif;tiff;png;"
        If Videos.checked Then ext = ext &  "mp4;mov;mpeg;mpg;wmv;mov;"
        If Notes.checked Then  ext = ext &  "id;"
        If CADUG.checked Then  ext = ext &  "dwg;dwt;dxf;dwf;dst;prt;"
        
        If Right(ext,1) = ";" Then
            ext = Left(ext,Len(ext) -1 )
        End If
        
        arrExtensions = Split(ext,";")
        
        SetDrivetoScan arrExtensions, strEndUserFolder
        
    End Sub
    Just add them up and remove the last extra one if it exists.


    ¯\_(ツ)_/¯

    • Marked as answer by JJ_1980 Monday, August 25, 2014 3:09 PM
    Friday, August 22, 2014 10:38 PM

All replies

  • I don't know VBScript, but that looks like it would be a whole lot simpler if you used a hash table, with the button names as the keys and arrays or collections of extension types as the values.

    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Friday, August 22, 2014 10:17 PM
    Moderator
  • Wow!  A hash table in VBScript would be a great extension.

    Sounds like a job for "ta-da!" ... Array Man!.

    Sub Extensions(strEndUserFolder)
    	
        ext=""
        If Office.checked Then ext=ext & "doc;docx;docm;xls;xlt;xlm;xlsx;xlsm;ppt;pps;pptx;pptm;ppsx;ppsm;mdb;ldb;one;onetoc2;"
        If PDF.checked Then ext = ext & "pdf;"
        If SRA.checked Then ext = ext & "rws;"
        If Pictures.checked Then ext = ext &  "bmp;jpg;jpeg;gif;tiff;png;"
        If Videos.checked Then ext = ext &  "mp4;mov;mpeg;mpg;wmv;mov;"
        If Notes.checked Then  ext = ext &  "id;"
        If CADUG.checked Then  ext = ext &  "dwg;dwt;dxf;dwf;dst;prt;"
        
        If Right(ext,1) = ";" Then
            ext = Left(ext,Len(ext) -1 )
        End If
        
        arrExtensions = Split(ext,";")
        
        SetDrivetoScan arrExtensions, strEndUserFolder
        
    End Sub
    Just add them up and remove the last extra one if it exists.


    ¯\_(ツ)_/¯

    • Marked as answer by JJ_1980 Monday, August 25, 2014 3:09 PM
    Friday, August 22, 2014 10:38 PM
  • You can also use an "ArrayList" or a Dictionary.  Both can work like a hash. 


    ¯\_(ツ)_/¯

    Friday, August 22, 2014 10:39 PM
  • You can also use an "ArrayList" or a Dictionary.  Both can work like a hash. 


    ¯\_(ツ)_/¯

    I thought a Dictionary was a hash.

    (And does Link Awray front for the Array Men?)


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "


    Friday, August 22, 2014 10:56 PM
    Moderator
  • Ok - It is a keyed collection which is not called a hash.  If you look up hash in VB-land you will not find the right answers.

    Actually....in VB...a string is easier to use to check for an extension.

    PowerShell can do this even easier.


    ¯\_(ツ)_/¯

    Friday, August 22, 2014 10:59 PM
  • Worked like a Charm.  Not sure why I did not think of doing that.  
    Monday, August 25, 2014 3:09 PM