WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: bottomleypotts on September 12, 2021, 12:12:28 AM

Title: Declaring Variables
Post by: bottomleypotts on September 12, 2021, 12:12:28 AM
I have a need to read through a file greater that 3Gb.

Code (winbatch) Select
a=Int64(2999947537)

x=500000000

For i=0 to a-1 by x
; do something
Next i


I know that I will have to do this as a while loop, but it would be nice to be able to explicitly declare i as an int64. Can anyone think of a way to do this?
Title: Re: Declaring Variables
Post by: stanl on September 12, 2021, 02:50:49 AM
Not sure I understand what is being read but you might want to look into WB's BinaryReadEx() function with this parameter


file-offset: zero-based offset into the file specifying where the data to be read starts. This parameter accepts a huge number or a 64-bit integer data type.


Title: Re: Declaring Variables
Post by: bottomleypotts on September 12, 2021, 04:35:06 AM
Stan, run the code. My issue is i is an integer and ends up being negative.
Title: Re: Declaring Variables
Post by: JTaylor on September 12, 2021, 07:30:29 AM
Will ObjectType() do what you need?

Jim
Title: Re: Declaring Variables
Post by: stanl on September 12, 2021, 08:21:32 AM
Quote from: bottomleypotts on September 12, 2021, 04:35:06 AM
Stan, run the code. My issue is i is an integer and ends up being negative.


Sorry, it was early in the morning and I was more focused on how a large file could be read, but for variable assignment, Jim's suggestion is probably correct.
Title: Re: Declaring Variables
Post by: bottomleypotts on September 12, 2021, 09:24:37 AM
No need to apologize Stan. I appreciate any and all help!

ObjectType() allows me to set a variable, but as soon as I create a for ... loop, the variable is reconfigured as an integer.

Appears as if a while ... loop is the only way to do this.
Title: Re: Declaring Variables
Post by: JTaylor on September 12, 2021, 09:38:10 AM
Didn't the previous WinBatch release provide what you need?   Trying to remember...there was something about 64bit integers.

Jim
Title: Re: Declaring Variables
Post by: JTaylor on September 12, 2021, 09:40:10 AM
Are you using version 2021C?  If not, look under the Beta section of the forum and read the description there and see if it is what you need.

Jim
Title: Re: Declaring Variables
Post by: bottomleypotts on September 12, 2021, 10:46:47 AM
Yes Jim, you are correct. I can initialize a variable with the Int64() function, and then increase it in a while ... loop.
Title: Re: Declaring Variables
Post by: td on September 13, 2021, 07:43:28 AM
Quote from: bottomleypotts on September 12, 2021, 12:12:28 AM
I have a need to read through a file greater that 3Gb.

Code (winbatch) Select
a=Int64(2999947537)

x=500000000

For i=0 to a-1 by x
; do something
Next i


I know that I will have to do this as a while loop, but it would be nice to be able to explicitly declare i as an int64. Can anyone think of a way to do this?

This works assuming 2021C. Is this what you want?

Code (winbatch) Select
For i=Int64(0) to a-1 by x
; do something
Next


In the above example variable "i" is a 64-bit integer which then works as a loop control variable.
Title: Re: Declaring Variables
Post by: bottomleypotts on September 13, 2021, 12:47:30 PM
This is exactly what I wanted. Thanks Tony.