Page 1 of 1

Just wondering...

Posted: Sun Nov 20, 2011 9:08 pm
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?

Re: Just wondering...

Posted: Sun Nov 20, 2011 9:32 pm
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

Re: Just wondering...

Posted: Sun Nov 20, 2011 9:38 pm
by RichAlgeni
Thomas, do you mean .i as opposed to .l (long)? That's what I meant. Sorry if my question was confusing!

Re: Just wondering...

Posted: Sun Nov 20, 2011 9:50 pm
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.

Re: Just wondering...

Posted: Sun Nov 20, 2011 9:57 pm
by RichAlgeni
Understood. Thanks!

Re: Just wondering...

Posted: Mon Nov 21, 2011 3:38 am
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.

Re: Just wondering...

Posted: Mon Nov 21, 2011 6:01 am
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!