Jump to content

Variable as an integer


Recommended Posts

OK,

I'm getting frustrated because this should be so simple yet it's giving me problems.

I'm using a 3rd party tool to create zip files for transfer to USB drives during data migrations. my issue is that I need to create a very simple array to tell the tool how big to make each section of the zip files (in bytes).

$Free = DriveSpaceFree("E:")
$isplitSize = Number(($Free - 10) * 1024 * 1024)
Dim $aFileSizeArray[2] = [$isplitSize, 0]

Really easy right?

except it's not seeing the value in the array. During trouble shooting I did a clipput($isplitSize) and then manually pasted that as the first value in the array and it worked fine. So i can only assume the value of $isplitSize is not being created as a true integer.

Any ideas?

Thanks,

Mike

Link to comment
Share on other sites

i tried number and int. they return a value, that's not the problem.

For some reason when I populate the first value in the array with what is returned, the 3rd party app doesn't see it.

If i populate the first value in the array manually with say, 112056254 it works fine.

Here is an example of how I verified it has something to do with how the variable is being created.

I ran this and then pasted the output into the array manually. I then run the script with the script again, this time with the value manual entered and everything works fine

$Free = DriveSpaceFree("E:")
$isplitSize = Number(($Free - 10) * 1024 * 1024)
;~ Dim $aFileSizeArray[2] = [$isplitSize, 0]
ClipPut($isplitSize)

Dim $aFileSizeArray[2] = [112603136, 0]
Edited by MikeOsdx
Link to comment
Share on other sites

Link to comment
Share on other sites

Here is the full script I'm using for testing.

as it is right now, if i run it, i get one big zip file that is a little over 300mb, meaning that for some reason it's not seeing the size value in the array.

if I un-remark the line: $isplitSize = 112654123 then I get two files that are 110mb and one that is 82mb

ps. my E: is a 128mb usb drive i'm using for testing. I wanted it small so I didn't have to test with huge files

my D: has mass quantity of free space.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Migration.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

$Free = DriveSpaceFree("E:")
$isplitSize = Number(($Free - 10) * 1024 * 1024)
;~ $isplitSize = 112654123
_ZipToDisk("D:\Downloads\SharePointDesigner.exe", $isplitSize)

Func _ZipToDisk($ItemList, $SplitBytes)
;Specify the max size for the split file in bytes
;~  MsgBox(0, "Bytes", $SplitBytes)
    Dim $aFileSizeArray[2] = [$SplitBytes, 0]
    Const $ZIP_ADD = 4
    Const $ZSO_MINORCANCEL = 2
    Const $ZSO_EXTERNALPROG = 4
    Const $ZSO_EXTPROGCANCEL = 8
    Const $THREADING_TIMEOUT = 30
    Fileinstall("dzactx.dll", @ScriptDir & "\")
    FileInstall("DZPROG32.exe", @ScriptDir & "\")

    $ObjZip = ObjCreate("dzactxctrl.dzactxctrl.1")
    if not IsObj($ObjZip) Then
        #RequireAdmin
        $dzReg = RunWait(@SystemDir & '\regsvr32.exe /s "' & @ScriptDir & '\dzactx.dll"', @SystemDir)
        if $dzReg = 0 Then
            $ObjZip = ObjCreate("dzactxctrl.dzactxctrl.1")
            if not IsObj($ObjZip) Then MsgBox(0, "Setup Completed", "Setup has been completed.  Please restart the Migration Wizard.")
        Else
            MsgBox(0, "Setup Failed", "Unable to properly register files required by the Migration Wizard.")
            Exit
        EndIf
    EndIf


;avoid display of errors through GDI of Server
    $ObjZip.QuietFlag = True
;~;setup the password for the zip file.
;~  $ObjZip.EncryptFlag = True
;~  $ObjZip.EncryptCode = $icrpt
;Compression type
    $ObjZip.CompressionFactor = 19
;set multivolume for multiple disks
    $MV_USEMULTI = 0x8000
    $MV_TOHD = 0x4000
    $ObjZip.MultiVolumeControl = $MV_USEMULTI + $MV_TOHD
    $ObjZip.FileSizeArray = $aFileSizeArray
;Display status through external App
    $ObjZip.ExtProgTitle = "Migration Copy status"
    $ObjZip.ZipSubOptions = $ZSO_MINORCANCEL + $ZSO_EXTERNALPROG + $ZSO_EXTPROGCANCEL
;Number of Seconds to wait on the prior thread if concurrent access is needed
    $ObjZip.WaitSeconds = $THREADING_TIMEOUT
;Name of ZIP File
    $ObjZip.ZIPFile = "D:\Temp\DynaZip\ZipSplit.zip"
;Name of Items that will appear in the ZIP File
    $ObjZip.ItemList = $ItemList
;Recurse through directories
    $ObjZip.RecurseFlag = True
;Don't include any directory items in the zip file
;~  $ObjZip.noDirectoryEntriesFlag = True
;Don't prefix the items with any path information
;~  $ObjZip.noDirectoryNamesFlag = True
;initiate the zip process
    $ObjZip.ActionDZ = $ZIP_ADD

;' Display Failure based on returned ErrorCode
    GUISetCursor(2,1);Change cursor back to an arrow
    Switch $ObjZip.ErrorCode    
        Case 0
    ;;; do nothing as this is successfull
            Return 1
        Case 9
            MsgBox(262208, "Migration Canceled", "The Migration process has been canceled.")
            Return
        Case Else
            MsgBox(262208, "Migration Failed", "The Migration process failed." & @CRLF & "Error Code:  " & $ObjZip.ErrorCode)
            Return
        EndSwitch
EndFunc
Edited by MikeOsdx
Link to comment
Share on other sites

  • Developers

Strange issue. looks like your formula also returns an Int as the commented line does when filling in the number yourself.

I don't have the DLL available so cannot do any other debugging.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Must be something with the calculated value.

This seems to work fine:

$isplitSize = number(String(($Free - 10) * 1024 * 1024))

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Must be something with the calculated value.

This seems to work fine:

$isplitSize = number(String(($Free - 10) * 1024 * 1024))

Yep that works for me too...

Weird, so I have to convert the variable to a string in order to convert into a number...

Thanks for the work around Jos.

Mike

Link to comment
Share on other sites

  • Developers

Yep that works for me too...

Weird, so I have to convert the variable to a string in order to convert into a number...

Thanks for the work around Jos.

Mike

Its not clear to me as yet why it works and Int() doesn't.

Do you have any description of the Com object, specificly $ObjZip.FileSizeArray ?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Its not clear to me as yet why it works and Int() doesn't.

Do you have any description of the Com object, specificly $ObjZip.FileSizeArray ?

Jos

I'm fine with the work around but it still makes me wonder if there is some unseen character or something that is being created in the drivespacefree that is creating the issue.

Below is all I got from the manual.

Mike

FileSizeArray Hidden Property

This property contains a VARIANT array representing a FileSize array of unsigned

long values. This FileSize array is used when creating a multi-volume zip file and

writing the individual split files to a hard drive. Each value in the array specifies the

maximum size in bytes that a corresponding split file may occupy. This property is

only used when the MultiVolumeControl property is activated and its

MV_USEMULTI and MV_TOHD bits are set (see page 188).

The first entry in the FileSize array (array element 0) specifies the default split file

size. The default will be used when there is no specific split file size entry in the

FileSize array. The last FileSize array element must be set to 0, which serves as a

terminator for the FileSize array. FileSize array elements 1 through n specify the

maximum size for a corresponding split file 001 through n. It is most efficient to

specify the split file sizes as an integer multiple of 512. Setting sizes below 65536

will result in file segment sizes of 65536 since the smallest compatible multi-volume

file segment allowed is 64K. Common media sizes are defined as follows:

// Common media sizes

#define FSA_FILESIZE360 362496L

#define FSA_FILESIZE720 730112L

#define FSA_FILESIZE1200 1213952L

#define FSA_FILESIZE1440 1457664L

#define FSA_FILESIZE2880 2931712L

Example: The following FileSize array elements would be used to create split files

on the hard drive suitable for storage on 1.44 MB floppy diskettes while reserving 10

KB (10240 bytes) on the first diskette.

FileSize Array Elements:

1457664 element 0

1447424 element 1

0 element 2

If the file created by the zip operation yields 4 split files:

¨ the first split file size would be 1447424 bytes (determined by element 1)

¨ the second and third split file sizes would be 1457664 (the default size specified by element 0)

¨ the fourth split file size would be less than or equal to 1457664 (the default size specified by

element 0)

Used when ActionDZ is set to: ZIP_ADD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...