Author Topic: Declaring Variables  (Read 299 times)

bottomleypotts

  • Newbie
  • *
  • Posts: 42
Declaring Variables
« on: September 12, 2021, 12:12:28 am »
I have a need to read through a file greater that 3Gb.

Code: Winbatch
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

  • Pundit
  • *****
  • Posts: 1572
Re: Declaring Variables
« Reply #1 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.



bottomleypotts

  • Newbie
  • *
  • Posts: 42
Re: Declaring Variables
« Reply #2 on: September 12, 2021, 04:35:06 am »
Stan, run the code. My issue is i is an integer and ends up being negative.

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: Declaring Variables
« Reply #3 on: September 12, 2021, 07:30:29 am »
Will ObjectType() do what you need?

Jim

stanl

  • Pundit
  • *****
  • Posts: 1572
Re: Declaring Variables
« Reply #4 on: September 12, 2021, 08:21:32 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

  • Newbie
  • *
  • Posts: 42
Re: Declaring Variables
« Reply #5 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.

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: Declaring Variables
« Reply #6 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

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: Declaring Variables
« Reply #7 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

bottomleypotts

  • Newbie
  • *
  • Posts: 42
Re: Declaring Variables
« Reply #8 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.

td

  • Tech Support
  • *****
  • Posts: 3947
    • WinBatch
Re: Declaring Variables
« Reply #9 on: September 13, 2021, 07:43:28 am »
I have a need to read through a file greater that 3Gb.

Code: Winbatch
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
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

  • Newbie
  • *
  • Posts: 42
Re: Declaring Variables
« Reply #10 on: September 13, 2021, 12:47:30 pm »
This is exactly what I wanted. Thanks Tony.