At what point do you suppose we should assign results from commands such as 'OpenFile', 'ReadFile', etc., to a .i integer variable when coding in 64 bit?
After all, two billion is an awfully large number to surpass.
Are there any commands right now that should NEVER result in, or be passed a 64 bit integer?
Just wondering...
- RichAlgeni
- Addict

- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: Just wondering...
You should always use integer for handles, objects and pointer! Not only on 64-Bit.
This is the fastest type and the required range.
Greetings - Thomas
This is the fastest type and the required range.
Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- RichAlgeni
- Addict

- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: Just wondering...
Thomas, do you mean .i as opposed to .l (long)? That's what I meant. Sorry if my question was confusing!
Re: Just wondering...
.l Long = 32-Bit
.q Quad = 64-Bit
.i Integer = Long on 32-Bit and Quad on 64-Bit, so it's always the right range for handles, pointers, objects.
.q Quad = 64-Bit
.i Integer = Long on 32-Bit and Quad on 64-Bit, so it's always the right range for handles, pointers, objects.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- RichAlgeni
- Addict

- Posts: 935
- Joined: Wed Sep 22, 2010 1:50 am
- Location: Bradenton, FL
Re: Just wondering...
Understood. Thanks!
-
ozzie
- Enthusiast

- Posts: 444
- Joined: Sun Apr 06, 2008 12:54 pm
- Location: Brisbane, Qld, Australia
- Contact:
Re: Just wondering...
Note that .i is the "initial default type" (see Define in the Help). In my program I don't use Define at all, and I omit the type from all integer variable definitions except within structures where you have to declare the type.
For example:
Just a personal preference. I guess some users would recommend defining the type for all variables.
For example:
Code: Select all
Protected iFileNo
Protected sFileName.s
...
sFileName = ...
iFileNo = OpenFile(#PB_Any, sFileName)
If iFileNo
etc
EndIfRe: Just wondering...
You can shorten it down to pretty much a single line if you use define.ozzie wrote:Note that .i is the "initial default type" (see Define in the Help). In my program I don't use Define at all, and I omit the type from all integer variable definitions except within structures where you have to declare the type.
For example:Just a personal preference. I guess some users would recommend defining the type for all variables.Code: Select all
Protected iFileNo Protected sFileName.s ... sFileName = ... iFileNo = OpenFile(#PB_Any, sFileName) If iFileNo etc EndIf
Code: Select all
define.l iFileNo, someVariable, superMegaAwesomeVariable
define.i masterOfTheUniverse, wEvent
define aString.s, aByte.b[edit] I think I misunderstood you! Sorry!
▓▓▓▓▓▒▒▒▒▒░░░░░
