Just wondering...

Everything else that doesn't fall into one of the other PB categories.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Just wondering...

Post by RichAlgeni »

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?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Just wondering...

Post by ts-soft »

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
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.
Image
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Just wondering...

Post by RichAlgeni »

Thomas, do you mean .i as opposed to .l (long)? That's what I meant. Sorry if my question was confusing!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Just wondering...

Post by ts-soft »

.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.
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.
Image
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Just wondering...

Post by RichAlgeni »

Understood. Thanks!
ozzie
Enthusiast
Enthusiast
Posts: 444
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: Just wondering...

Post by ozzie »

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:

Code: Select all

Protected iFileNo
Protected sFileName.s
...
sFileName = ...
iFileNo = OpenFile(#PB_Any, sFileName)
If iFileNo
   etc
EndIf
Just a personal preference. I guess some users would recommend defining the type for all variables.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Just wondering...

Post by Nituvious »

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:

Code: Select all

Protected iFileNo
Protected sFileName.s
...
sFileName = ...
iFileNo = OpenFile(#PB_Any, sFileName)
If iFileNo
   etc
EndIf
Just a personal preference. I guess some users would recommend defining the type for all variables.
You can shorten it down to pretty much a single line if you use define.

Code: Select all

define.l iFileNo, someVariable, superMegaAwesomeVariable
define.i masterOfTheUniverse, wEvent
define aString.s, aByte.b
It helps keep things looking nice and clean. You can also apply the same thing to other variable identifiers.

[edit] I think I misunderstood you! Sorry!
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply