Declaring Variables

Started by bottomleypotts, September 12, 2021, 12:12:28 AM

Previous topic - Next topic

bottomleypotts

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?

stanl

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.



bottomleypotts

Stan, run the code. My issue is i is an integer and ends up being negative.

JTaylor

Will ObjectType() do what you need?

Jim

stanl

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.

bottomleypotts

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.

JTaylor

Didn't the previous WinBatch release provide what you need?   Trying to remember...there was something about 64bit integers.

Jim

JTaylor

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

bottomleypotts

Yes Jim, you are correct. I can initialize a variable with the Int64() function, and then increase it in a while ... loop.

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bottomleypotts

This is exactly what I wanted. Thanks Tony.