I have researched the forums and have seen many ways to pass a value by reference and am now confused as the which is the best method. In VisualBasic 6 and PowerBasic you can specify the keyword "ByRef", so I am simply looking for the equivalent way in PureBasic. :D
The following works, but is it ...
Search found 29 matches
- Wed Jan 29, 2014 12:46 am
- Forum: Coding Questions
- Topic: How to pass by reference ByRef
- Replies: 4
- Views: 1528
- Sat Jun 09, 2012 9:42 pm
- Forum: Coding Questions
- Topic: Problem using PB64 with 3rd Party 64-bit App
- Replies: 11
- Views: 2318
Re: Problem using PB64 with 3rd Party 64-bit App
As another quick test, I tried the following code which returns "112596307.00"
Code: Select all
ProcedureDLL.d ReturnDouble()
ProcedureReturn 7.123
EndProcedure
- Sat Jun 09, 2012 9:35 pm
- Forum: Coding Questions
- Topic: Problem using PB64 with 3rd Party 64-bit App
- Replies: 11
- Views: 2318
Re: Problem using PB64 with 3rd Party 64-bit App
Hi srod, thanks for your correction. Now I have it exactly like yours. The output from 3rd party app is "0". Here is the output from the log file:
2012-06-09, 16:27:59:: v20120609-1424 AddFloat:3.1400001049 + 2.1500000954 = 5.2899999619, PeekL=1084835758
EnableExplicit
#DebugLog = 1 ; Off=0 ...
2012-06-09, 16:27:59:: v20120609-1424 AddFloat:3.1400001049 + 2.1500000954 = 5.2899999619, PeekL=1084835758
EnableExplicit
#DebugLog = 1 ; Off=0 ...
- Sat Jun 09, 2012 7:27 pm
- Forum: Coding Questions
- Topic: Problem using PB64 with 3rd Party 64-bit App
- Replies: 11
- Views: 2318
Re: Problem using PB64 with 3rd Party 64-bit App
Thanks srod for the suggestion. Unfortunately, it did not work. Here's the snippet of modified code. I put in your changes and also output some info to a log file:
ProcedureDLL.f AddFloat(num1.f, num2.f)
Protected Mysum.f
Mysum = num1 + num2
CompilerIf #DebugLog=1
PrintToFile("v20120609-1417 ...
ProcedureDLL.f AddFloat(num1.f, num2.f)
Protected Mysum.f
Mysum = num1 + num2
CompilerIf #DebugLog=1
PrintToFile("v20120609-1417 ...
- Sat Jun 09, 2012 3:24 pm
- Forum: Coding Questions
- Topic: Problem using PB64 with 3rd Party 64-bit App
- Replies: 11
- Views: 2318
Problem using PB64 with 3rd Party 64-bit App
I wrote the following simple 64 bit DLL and am unable to get it to work with a 3rd party application called Multicharts64. The problem seems to be when I try to return a double or float. I'm using PB64 v4.61.
EnableExplicit
; These 4 procedures are Windows specific
;
; This procedure is called ...
EnableExplicit
; These 4 procedures are Windows specific
;
; This procedure is called ...
- Sun Jun 03, 2012 7:35 pm
- Forum: Coding Questions
- Topic: Assigning Bitwise AND to Double
- Replies: 4
- Views: 877
Re: Assigning Bitwise AND to Double
Yikes, a newbie mistake. 

- Sat Jun 02, 2012 11:55 pm
- Forum: Coding Questions
- Topic: Visual Basic and PureBasic DLLs
- Replies: 16
- Views: 2882
Re: Visual Basic and PureBasic DLLs
I justed wanted to let Addict know his old post was still useful and appreciated. It's a great forum and offers tons of great knowledge.
- Sat Jun 02, 2012 11:21 pm
- Forum: Coding Questions
- Topic: Visual Basic and PureBasic DLLs
- Replies: 16
- Views: 2882
Re: Visual Basic and PureBasic DLLs
Addict,
Thank you for your great VB to PB example. It is much appreciated and works perfect.
Thank you for your great VB to PB example. It is much appreciated and works perfect.

- Sat Jun 02, 2012 5:35 pm
- Forum: Coding Questions
- Topic: TypeCast double to integer for Array( Index )
- Replies: 5
- Views: 1375
Re: TypeCast double to integer for Array( Index )
The 3rd party app is passing me an array of doubles. The array is multi purpose whereby sometimes the values in the array are to be used as doubles in math calculations, yet other times, as in my case, as an array index.
- Fri Jun 01, 2012 4:53 pm
- Forum: Coding Questions
- Topic: TypeCast double to integer for Array( Index )
- Replies: 5
- Views: 1375
Re: TypeCast double to integer for Array( Index )
Is this more efficient?
Code: Select all
Define d1.d, i1.i
Dim MyArray.d(10)
d1 = 2.0
i1 = d1
MyArray( i1 ) = 123.45
- Fri Jun 01, 2012 4:47 pm
- Forum: Coding Questions
- Topic: Assigning Bitwise AND to Double
- Replies: 4
- Views: 877
Re: Assigning Bitwise AND to Double
Thank you Addict for the code for Logical And on doubles.
I would appreciate your input on my array index question also. Sorry if it seems silly, but I'm new to PB and am just trying to make sure I'm not coding it inefficiently.
Thank you.
I would appreciate your input on my array index question also. Sorry if it seems silly, but I'm new to PB and am just trying to make sure I'm not coding it inefficiently.
Thank you.
- Thu May 31, 2012 11:09 pm
- Forum: Coding Questions
- Topic: TypeCast double to integer for Array( Index )
- Replies: 5
- Views: 1375
TypeCast double to integer for Array( Index )
The following causes compiler to hiccup:
Define d1.d
Dim MyArray.d(10)
d1 = 2.0
MyArray( d1 ) = 123.45
So I changed it to this which works:
Define d1.d
Dim MyArray.d(10)
d1 = 2.0
MyArray( Int(d1) ) = 123.45
Question:
My snippet is just to demonstrate the issue where my index is being ...
Define d1.d
Dim MyArray.d(10)
d1 = 2.0
MyArray( d1 ) = 123.45
So I changed it to this which works:
Define d1.d
Dim MyArray.d(10)
d1 = 2.0
MyArray( Int(d1) ) = 123.45
Question:
My snippet is just to demonstrate the issue where my index is being ...
- Thu May 31, 2012 10:50 pm
- Forum: Coding Questions
- Topic: Assigning Bitwise AND to Double
- Replies: 4
- Views: 877
Assigning Bitwise AND to Double
I am trying to do the following:
Define d1.d, d2.d, d3.d
d1 = Int(d2) & Int(d3)
Which throws compiler error "Can't use any of the following operands with floats: <<,>>,&..."
If I change it to this it works:
Procedure.d Double( MyInt.i )
ProcedureReturn MyInt
EndProcedure
Define d1.d, d2.d ...
Define d1.d, d2.d, d3.d
d1 = Int(d2) & Int(d3)
Which throws compiler error "Can't use any of the following operands with floats: <<,>>,&..."
If I change it to this it works:
Procedure.d Double( MyInt.i )
ProcedureReturn MyInt
EndProcedure
Define d1.d, d2.d ...
- Wed May 30, 2012 2:57 pm
- Forum: Coding Questions
- Topic: How to do Log2 ?
- Replies: 10
- Views: 2639
Re: How to do Log2 ?
Thank you for your excellent replies.
- Tue May 29, 2012 10:47 pm
- Forum: Coding Questions
- Topic: How to do Log2 ?
- Replies: 10
- Views: 2639
How to do Log2 ?
I need the function Log2 and came up with the following:
Define x.d, num.d
x = 8
num = Log(x)/Log(2)
which gives num = 2.99999999999996 which is close but not exact. The exact answer is 3 which is 2^3 = 8 or Log2(8) = 3. Perhaps this difference is due to floating point error.
QUESTION:
Is ...
Define x.d, num.d
x = 8
num = Log(x)/Log(2)
which gives num = 2.99999999999996 which is close but not exact. The exact answer is 3 which is 2^3 = 8 or Log2(8) = 3. Perhaps this difference is due to floating point error.
QUESTION:
Is ...