Sign in to follow this  
Followers 0
ChrisJakarta

Object value can't be set True

9 posts in this topic

I have been trying to implement programming of Open Office through AutoIt. Open Office requires the passing of an object to its loadComponentFromURL function. This object consists of a Name and a Value, and is used to pass various information on the file, such as password (passes a string value) and Readonly (passes a boolean).

I have implemented a function to set up this up, based on several examples in these forums. However, I find that while this passes strings OK, it apparently cannot be used to set boolean values to true - whatever I try, it stays as false.

Here's a quick and dirty example which demonstrates this:

Dim $OpenPar

; This returns object with both fields correct
$OpenPar = MakePropertyValue("Password", "secret")

; This returns object with value False as requested
$OpenPar = MakePropertyValue("ReadOnly", False)

; This returns object with Vlue False, not True as reuqested
$OpenPar = MakePropertyValue("ReadOnly", True)

Exit

Func MakePropertyValue($cName, $uValue)
    $oSM = Objcreate("com.sun.star.ServiceManager")
    $oPropertyValue = $oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
    $oPropertyValue.Name = $cName
    $oPropertyValue.Value = $uValue
    MsgBox(0,$oPropertyValue.Name,$oPropertyValue.Value)
    $setOOoProp = $oPropertyValue
    Return $setOOoProp
EndFunc

Has anyone any idea why this does not work correctly (the vbs version works perfectly)? Am I facing a bug, or is there something I'm doing wrong?

Chris

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Did you try passing a literal number one for true?

Edit:

I see you're just stumbling over the same issue ( function even ) here:

http://www.autoitscript.com/forum/index.php?showtopic=22969&view=findpost&p=750382

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Did you try passing a literal number one for true?

Yes, indeed. I tired just about every combination I could think of

Edit:

I see you're just stumbling over the same issue ( function even ) here:

http://www.autoitscript.com/forum/index.php?showtopic=22969&view=findpost&p=750382

Sorry, I missed that. But it does seem that this is a well-documented and quite long standing bug, if rather arcane. But it is essential for successful automation of Open Office. Is there a way it can be escalated?

Chris

Share this post


Link to post
Share on other sites

I don't expect this to make a difference, but it is worth a try if there is some subtle difference between how True is internally represented in VBS and AutoIt. I needed this workaround due to AutoIt "" no necessarily being the same as VBS Nothing. Try using $vbTrue in your script:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $vbNothing = $oVBS.eval("Nothing")
Global Const $vbTrue = $oVBS.eval("True")
Global Const $vbFalse = $oVBS.eval("False")
$oVBS = $vbNothing

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I don't expect this to make a difference, but it is worth a try if there is some subtle difference between how True is internally represented in VBS and AutoIt. I needed this workaround due to AutoIt "" no necessarily being the same as VBS Nothing. Try using $vbTrue in your script:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $vbNothing = $oVBS.eval("Nothing")
Global Const $vbTrue = $oVBS.eval("True")
Global Const $vbFalse = $oVBS.eval("False")
$oVBS = $vbNothing

Dale

Dale,

Thanks for the idea. However, as you suspected, it doesn't seem to help.

The VBS definition of True appears to be 0Xffffffff, but I'm not sure how that might be implemented in AutoIt.

I've also tried Running the VBS script from AutoIt, which (perhaps unsurprisingly) works. But I don't know how to pass and retrieve parameters to an external script (if it is possible, which I doubt), so that doesn't help me.

Not sure where to go from here. Is it correct to call this a bug?

Chris

Share this post


Link to post
Share on other sites

Well, you can actually use the ScriptControl as above to run your VBS code... using the .eval method just as above... you'll just need to execute it ine by line without the function call.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I had been waiting patiently for changes to the object programming in v3.3.8.0, hoping that they would address this problem. Sad to say, this does not appear to be the case - the problem of passing booleans still remains. Has anybody any ideas of a work around? Is this a bug (as it appears to me to be)?

Until this is addressed, I will not be able to migrate my programs from Word to OpenOffice/LibreOffice...

Chris

Share this post


Link to post
Share on other sites

@ChrisJakarta

Why don't you create a ticket on it so the devs can have a look. See the link at the top of your screen that says "BugTracker"? Click it, read the guidelines, and "New Ticket".

Share this post


Link to post
Share on other sites

@AdmiralAlkex

Thanks for giving me the confidence to report this as a bug. I did so, and there was an immediate response to say it will be corrected in v3.3.9.0.

Chris

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0