Bug 33964 - Passing a Byref variable doesn't work in a Declare statement
Summary: Passing a Byref variable doesn't work in a Declare statement
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: Noel Power
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-06 05:42 UTC by paslebihan
Modified: 2013-02-05 14:37 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description paslebihan 2011-02-06 05:42:59 UTC
The following code is intended to retrieve the current printer. It works in OpenOffice but doesn't work in LibreOffice : calling GetProfileString in Main() returns no value in strbuffer (passed by reference).


Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByRef lpReturnedString As String, ByVal nSize As Long) As Long 


Sub Main
	Dim strBuffer as String
	Dim iRetValue as Long
	
	strbuffer = string (254)
	iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
	msgbox (cstr(iretvalue) + " " + strbuffer)
End Sub
Comment 1 Noel Power 2011-02-07 01:44:25 UTC
I'll take a look at this
Comment 2 Noel Power 2011-02-14 04:37:04 UTC
this is also an error in oracle office builds ( see.http://qa.openoffice.org/issues/show_bug.cgi?id=115716 ), we should have the fix for 3.3.2 at least
Comment 3 BSC 2011-04-14 11:01:47 UTC
(In reply to comment #0)

I had the same problem with various functions similar to this one:

Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long,  ByVal lpBuffer As String) As Long

With OpenOffice 3.3.0, I must remove the "ByVal" before lpBuffer.
With LibreOffice 3.3.2, I must put the "ByVal" before lpBuffer.

I don't know who is right, but this incompatibility is annoying...

Seen on Windows (XP and Vista)
Comment 4 Noel Power 2013-02-05 14:37:36 UTC
seen fixed in recent builds ( 4.0 at least )