Jump to content

Variant Type Nothing


IMTS
 Share

Recommended Posts

Any AutoIt Gurus or Developers wish to comment on how the Variant value Nothing as used in VB, VBScript etc. may be implemented in AutoIt?

I have tried searching this forum and have found a number of posters have apparently battled with this issue but have not found a satisfactory answer, apart from "Cannot be done".

In VBScript, VB etc. etc. Nothing is a keyword. It means an unassigned (empty) Object type.

In the Microsoft languages assigning a variable this value is used to release an assigned object from memory (kind of a null pointer) but the value has some additional special properties: it is not Null or Empty and it can also be passed as an argument to a COM Object method or property.

Now the "memory release" aspect can be accomplished in AutoIt by doing:

$MyVar = 0

but the other properties cannot be accomplished with this. In particular, the last item can be used to pass an empty (not required) interface into COM object methods where, when used, a valid object would be supplied.

The latest version has introduced the functionality to call COM but does not seem to support this critical aspect of COM meaning that I have some some ActiveX components I am currently unable to use from AutoIt because I simply cannot call some of their functionality correctly.

Come to think of it, Null and Empty are also valid variant types (and keywords), along with Nothing, which do not seem possible to assign with AutoIt even though it uses "Variant" types?

While we are at it, does anyone know if AutoIt can be made to call the secondary interfaces of polymorphic COM objects? Strongly typed languages such as VB assign different variable declarations to the different interface objects and then set the objects as equal to obtain the secondary interfaces. VBScript cannot support implementing this functionality but, in some respects, AutoIt is very much more powerful than VBScript so it might be made possible, maybe by some clever manipulation with the DLL call functionality? Like VBScript the ObjCreate and ObjGet functions can be used to obtain the default interface but how can we reach the others?

Any Help welcome.

I suspect the answer will require the Developers to add something like @NOTHING, @NULL and @EMPTY to the implementation but the COM functionality will not be complete until this is done, which seems a pity to me because I quite like the apparent power of AutoIt.

Link to comment
Share on other sites

Hi Valik,

Thanks, did try that already but does not work in the specific case I am trying to deal with. I get an error raised from the object I am calling so that I cannot continue. The AutoIt keyword Default is not the same as Nothing apparently. But then I would expect that - in the specific case I am using it is not that I am trying to not supply an argument (and thus use a "default" value) rather it is that the Interface variable to be assigned should be "Nothing" meaning that it is not being used. I cannot create a "Nothing" object in AutoIt.

I suspect that possibly a solution may involve creating a structure in memory which "looks" like a variant value set to "Nothing". Unfortunately I do not know what this should look like perhaps some C/C++ API programmer can shed some light on what VT_ flags are used for "Nothing" along with the rest of the structure? Presumably somewhere in there will be a value which should be a pointer to the default interface function which in the case of "Nothing" must be NULL, maybe?

Link to comment
Share on other sites

Valik,

Would love to provide an example but unfortunately I cannot, off the top of my head, think of any "common" objects that people would have access to which will behave this way or require this very specific functionality. The case I am dealing with is for the API to a particular document management system but the general user base is unlikely to have access to this.

I can certainly post the test code I am working with in both AutoIt and vb script:

Option Explicit
Const AMVAULTLINK_OPEN_DEFAULT = 0
Const AMVAULTLINK_OPEN_ENVIRONMENT_CACHED = 1
Const AMVAULTLINK_OPEN_USERMODE = 2
Const AMVAULTLINK_OPEN_AUTOCOMMIT = 4

Const AMOB_DLGTYPE_FOLDER = 0
Const AMOB_DLGTYPE_ASSIGN2WA = 1
Const AMOB_DLGTYPE_UNDELETE = 2
Const AMOB_DLGTYPE_SELECTDOCREFS = 3
Const AMOB_DLGTYPE_SELECTSINGLEDOC = 4
Const AMOB_DLGTYPE_FOLDER_RO = 5

Const AMEDM_FLG_READONLY = 32

Const AMStallID = "{05373712-38F0-11D3-A409-00E0291B82AD}"
Const MetaDataID = "{CD0AA9D2-5CE4-41f5-A849-72A1DCF6E393}"

Public Sub Main()

    Dim oAmOpenVault
    Dim oAMVaultLink
    Dim oAMDocumentRepository
    Dim oAMObjectBrowser
    Dim oAMDocument
    Dim oAMEDMComDlg
    Dim oAMServiceProvider
    Dim oAMStall
    Dim oAMScriptObject
    Dim oIAMMetaDataService


    Dim strOID
    Dim lngHWnd

    lngHWnd = Clng(0)


    Set oAmOpenVault = CreateObject("AmVault.AMOpenVault")
    oAMOpenVault.Caption = "Choose the vault"

    oAMOpenVault.ShowDatastores = True
    oAMOpenVault.ShowDateTime = False
    oAMOpenVault.ShowWorkPackages = False

    If oAMOpenVault.Show(lngHWnd) Then

        Set oAMVaultLink = oAMOpenVault.SelectedVault

        'Debug info only
        'MsgBox _
        ' Join _
        '    ( _
        '    Array _
        '        ( _
        '       oAmVaultLink.MachineName, _
        '       oAmVaultLink.DataStoreName, _
        '       oAmVaultLink.VaultName, _
        '       oAmVaultLink.WorkPackageID, _
        '       oAmVaultLink.DateTimeUTC _
        '       ), _
        '   vbCrLf _
        '   )

        oAMVaultLink.OpenFlags = AMVAULTLINK_OPEN_DEFAULT

        Set oAMDocumentRepository = oAmVaultLink.CreateVault(Nothing)
        Set oAMObjectBrowser = CreateObject("AmEdmUI.AMObjectBrowser")
        oAMObjectBrowser.Caption = "Select a document"
        oAMObjectBrowser.Description = "Please select a document:"

        Set oAMObjectBrowser.Repository = oAMDocumentRepository
        If _
            oAMObjectBrowser.SelectObjectDlg _
                ( _
                AMOB_DLGTYPE_SELECTSINGLEDOC, _
                lngHWnd _
                ) _
        Then

            strOID = oAMObjectBrowser.SelectedItemID
            Set oAMDocument = oAMDocumentRepository.GetFSObject(strOID)

            Set oAMServiceProvider = CreateObject("AMUILib.AMServiceProvider")
            Set oAMStall = CreateObject("AmOmlUI.AMStall")
    
            oAMServiceProvider.Service(AMStallID) = oAMStall

            'Lines commented out here are because VBScript cannot

            'access the secondary interface
            'of this object so these methods do not work!!


            'Set oIAMMetaDataService = CreateObject("AmEdmUI.AMScriptObject") 'IAMMetaDataService   
    
            'Call oIAMMetaDataService.SetContext _
               ( _
               oAMDocumentRepository, _
               lngHWnd, _
               oAMServiceProvider_
               )

            'oIAMMetaDataService.LoadMetaData
            'Call oIAMMetaDataService.SetContext( Nothing,lngHWnd, oAMServiceProvider)
    

            'oAMServiceProvider.Service(MetaDataID) = oIAMMetaDataService
    
            Set oAMEDMComDlg = CreateObject("AmEdmUI.AMEdmComDlg")
            Call oAMEDMComDlg.Properties _
                ( _
                oAMDocument, _
                lngHWnd, _
                oAMServiceProvider, _
                AMEDM_FLG_READONLY _
                )
            Set oAMEDMComDlg = Nothing

            'Set oIAMMetaDataService = oAMServiceProvider.Service(MetaDataID)
            'oIAMMetaDataService.Close
            'Set oIAMMetaDataService = Nothing
    
            Set oAMStall = Nothing
            Set oAMServiceProvider = Nothing
    
            Set oAMDocument = Nothing
        End If

        Set oAMObjectBrowser = Nothing

        oAmDocumentRepository.CloseRepository False
        Set oAmDocumentRepository = Nothing

        Set oAMVaultLink = Nothing
    End If

    Set oAmOpenVault = Nothing


End Sub

Main

AutoIt translation (Failed):

Opt("MustDeclareVars", 1)

Global Const $AMVAULTLINK_OPEN_DEFAULT = 0
Global Const $AMVAULTLINK_OPEN_ENVIRONMENT_CACHED = 1
Global Const $AMVAULTLINK_OPEN_USERMODE = 2
Global Const $AMVAULTLINK_OPEN_AUTOCOMMIT = 4

Global Const $AMOB_DLGTYPE_FOLDER = 0
Global Const $AMOB_DLGTYPE_ASSIGN2WA = 1
Global Const $AMOB_DLGTYPE_UNDELETE = 2
Global Const $AMOB_DLGTYPE_SELECTDOCREFS = 3
Global Const $AMOB_DLGTYPE_SELECTSINGLEDOC = 4
Global Const $AMOB_DLGTYPE_FOLDER_RO = 5

Global Const $AMEDM_FLG_READONLY = 32

Global Const $AMStallID = "{05373712-38F0-11D3-A409-00E0291B82AD}"
Global Const $MetaDataID = "{CD0AA9D2-5CE4-41f5-A849-72A1DCF6E393}"

;MessageBox constants

Global Const $MB_ABORTRETRYIGNORE=0x2
Global Const $MB_CANCELTRYCONTINUE=0x6
Global Const $MB_HELP=0x4000
Global Const $MB_OK=0x0
Global Const $MB_OKCANCEL=0x1
Global Const $MB_RETRYCANCEL=0x5
Global Const $MB_YESNO=0x4
Global Const $MB_YESNOCANCEL=0x3
Global Const $MB_ICONEXCLAMATION=0x30
Global Const $MB_ICONASTERISK=0x40
Global Const $MB_ICONWARNING=$MB_ICONEXCLAMATION
Global Const $MB_ICONINFORMATION=$MB_ICONASTERISK
Global Const $MB_ICONHAND=0x10
Global Const $MB_ICONQUESTION=0x20
Global Const $MB_IConstop=$MB_ICONHAND
Global Const $MB_IConerror=$MB_ICONHAND
Global Const $MB_DEFBUTTON1=0x0
Global Const $MB_DEFBUTTON2=0x100
Global Const $MB_DEFBUTTON3=0x200
Global Const $MB_DEFBUTTON4=0x300
Global Const $MB_APPLMODAL=0x0
Global Const $MB_SYSTEMMODAL=0x1000
Global Const $MB_TASKMODAL=0x2000
Global Const $MB_DEFAULT_DESKTOP_ONLY=0x20000
Global Const $MB_RIGHT=0x80000
Global Const $MB_RTLREADING=0x100000
Global Const $MB_SETFOREGROUND=0x10000
Global Const $MB_TOPMOST=0x40000
Global Const $MB_SERVICE_NOTIFICATION=0x40000
Global Const $MB_SERVICE_NOTIFICATION_NT3X=0x40000

Global Const $IDABORT=3 ;Abort button was selected. 
Global Const $IDCANCEL=2 ;Cancel button was selected. 
Global Const $IDCONTINUE=11 ;Continue button was selected. 
Global Const $IDIGNORE=5 ;Ignore button was selected. 
Global Const $IDNO=7 ;No button was selected. 
Global Const $IDOK=1 ;OK button was selected. 
Global Const $IDRETRY=4 ;Retry button was selected. 
Global Const $IDTRYAGAIN=10 ;Try Again button was selected. 
Global Const $IDYES=6 ;Yes button was selected. 


Func Main()

    Dim $oAmOpenVault
    Dim $oAMVaultLink
    Dim $oAMDocumentRepository
    Dim $oAMObjectBrowser
    Dim $oAMDocument
    Dim $oAMEDMComDlg
    Dim $oAMServiceProvider
    Dim $oAMStall
    Dim $oAMScriptObject
    Dim $oIAMMetaDataService

    Dim $strOID
    Dim $hWnd = 0

    $oAMOpenVault = ObjCreate("AmVault.AMOpenVault")
    $oAMOpenVault.Caption = "Choose the vault"

    $oAMOpenVault.ShowDatastores = True
    $oAMOpenVault.ShowDateTime = False
    $oAMOpenVault.ShowWorkPackages = False

 

    If $oAMOpenVault.Show($hWnd) Then
        $oAMVaultLink = $oAMOpenVault.SelectedVault()
        MsgBox( _
            BitOR($MB_OK,$MB_ICONINFORMATION), _
            "AutoIt Testing", _
            $oAMVaultLink.MachineName & @CRLF & _
            $oAMVaultLink.DataStoreName & @CRLF & _
            $oAMVaultLink.VaultName & @CRLF & _
            $oAMVaultLink.WorkPackageID & @CRLF & _
            $oAMVaultLink.DateTimeUTC _
        )
   

        $oAMVaultLink.OpenFlags = $AMVAULTLINK_OPEN_DEFAULT

#cs
        *******************
        The line below generates an error exiting the code
        This is where I need Nothing
        Have also tried passing 0 and unassigned AutoIt variable without
        success
        Also have attempted to use AutoIt DLL functionality to try to get
        Null Pointer effect but not success either.
        Leaving in "Default" for now as makes no difference!
#ce
        $oAMDocumentRepository = $oAMVaultLink.CreateVault(Default)

        $oAMObjectBrowser = ObjCreate("AmEdmUI.AMObjectBrowser")
        $oAMObjectBrowser.Caption = "Select a document"
        $oAMObjectBrowser.Description = "Please select a document:"

        $oAMObjectBrowser.Repository = $oAMDocumentRepository
        If _
            $oAMObjectBrowser.SelectObjectDlg _
                ( _
                $AMOB_DLGTYPE_SELECTSINGLEDOC, _
                $hWnd _
                ) _
        Then
            $strOID = $oAMObjectBrowser.SelectedItemID
            $oAMDocument = $oAMDocumentRepository.GetFSObject($strOID)

            $oAMServiceProvider = ObjCreate("AMUILib.AMServiceProvider")
            $oAMStall = ObjCreate("AmOmlUI.AMStall")
     
            $oAMServiceProvider.Service($AMStallID) = $oAMStall

#cs
            These lines probably will not work in AutoIt either but have been
            added back in for testing -
            we are not getting this far so is redundant!!
#ce
            $oIAMMetaDataService = _
                ObjCreate("AmEdmUI.AMScriptObject") ;IAMMetaDataService
     
     
            $oIAMMetaDataService.SetContext _
                ( _
                $oAMDocumentRepository, _
                $hWnd, _
                $oAMServiceProvider _
                )
            $oIAMMetaDataService.LoadMetaData
            
            ;This wont work either, as above
            $oIAMMetaDataService.SetContext _
                ( _
                Default, _
                $hWnd, _
                $oAMServiceProvider _
                )
     
            $oAMServiceProvider.Service($MetaDataID) = $oIAMMetaDataService
     
            $oAMEDMComDlg = ObjCreate("AmEdmUI.AMEdmComDlg")
            $oAMEDMComDlg.Properties _
                ( _
                $oAMDocument, _
                $hWnd, _
                $oAMServiceProvider, _
                $AMEDM_FLG_READONLY _
                )
            $oAMEDMComDlg = 0

            $oIAMMetaDataService = $oAMServiceProvider.Service($MetaDataID)
            $oIAMMetaDataService.Close
            $oIAMMetaDataService = 0
     
            $oAMStall = 0
            $oAMServiceProvider = 0
     
            $oAMDocument = 0
        EndIf
        $oAMObjectBrowser = 0

        $oAMDocumentRepository.CloseRepository(False)
        $oAMDocumentRepository = 0
  
        $oAMVaultLink = 0
    EndIf
    $oAMOpenVault = 0
EndFunc

Main()

The simplest answer is that AutoIt is not the tool for the job anyway but it was an interesting exercise to see if it could be done - also wanted to see if AutoIt's additional functionality might give a mechanism (probably using direct Windows API and DLL calls) to the secondary interface problem that effects VBScript.

Any bright sparks looking for the intellectual challenge are welcome to post (polite) suggestions!!

$#!+ does this editor mess with the indenting or what....this is the fourth edit to try to make the post readable!

Edited by IMTS
Link to comment
Share on other sites

I don't see that you've ever actually told anybody what the error is. I don't see a registered COM error handler in that code, either.

A piece of advice, lose the tech talk. Please stop speculating if or how AutoIt does this particular thing. Leave the determination of whether or not this is possible to us. You've speculated AutoIt can't do it and that there is no analogous feature in AutoIt, which is wrong on both counts. The Default keyword is designed for this sort of thing or there is some other simple way to do it. COM, contrary to many claims, is not magical.

Post the code, the error (In this case, the error from a COM error handler will be useful) and what you've tried. The rest of your technical jargon isn't really doing anything other than making me less interested in helping you.

Link to comment
Share on other sites

To Larry:

All of those suggestions have been tried and error out the same way. I would expect this as those arguments are all the wrong type. Variants do still have internally assigned types and neither 0 or "" is an object. In MS languages the variant values; Nothing, Empty and Null; can all be used as arguments as well as assignments.

To Valik:

Don't take offence - I am technical, it is what I am employed as, hence I tend to use technical language. The problem is a technical one and is best described in technical terms. The technical jargon tells you what I have already tried, including error trapping, even if I have not posted every single detail here.

I have already reported that the use of AutoIt keyword "Default" does not work whether or not you believe it should cope with this scenario.

Adding a COM Error handler simply traps the error, as expected, but does not resolve anything. You can add the following code before the Main func already posted if you wish:

Global Const $MB_OK=0x0
Global Const $MB_ICONEXCLAMATION=0x30


Global $oCOMError = ObjEvent("AutoIt.Error","COMErrHandler")

Func COMErrHandler()
 Dim $HexErrNumber
  $HexErrNumber=hex($oCOMError.number,8)    ; for displaying purposes
  Msgbox _
 ( _
 BitOR ($MB_OK,$MB_ICONEXCLAMATION), _
 "AutoItCOM Test", _
 "We intercepted a COM Error !"     & @CRLF & @CRLF & _
             "err.description is: "    & @TAB & $oCOMError.description    & @CRLF & _
             "err.number is: "         & @TAB & "0x" & $HexErrNumber      & @CRLF & _
             "err.scriptline is: "     & @TAB & $oCOMError.scriptline     & @CRLF _
    )
 SetError(1)
EndFunc

For information the Err.Number is 0x80020005 with no further error description but this error code is a "Type mismatch" which is not a surprise. That is what I have been saying all along - I have no way of supplying the required type from AutoIt which, in this case requires to be Nothing. All suggestions given so far raise this type error. Having failed at that point then various other errors occur later on because the code, as written, does not try to handle every little error and is not expected to fail at the particular method call. If it worked correctly then there would be no error here. The VBScript equivalent does not raise any errors and neither should they because these code fragments come from the VB6 original code which works fine - there is nothing wrong with the basic coding logic being used. Omitting error handling is just to simplify things.

I have done a little more digging around assuming a simplistic definition of a Variant structure as 4 DWORDS = 16 Bytes with the first DWORD giving the variant type then "Nothing" has a variant type of VT_DISPATCH but with all other values 0. "Empty" is variant type VT_EMPTY with all other values 0 and "Null" is VT_NULL with all other values 0. If you believe that AutoIt can create and handle variable of these specific values then I am simply asking how would you create them? VBScript, VB etc. has keyword (constants) for them. AutoIt does not appear to have an equivalent. Both languages claim to use variants so there should be no reason why AutoIt cannot do this.

It does not add anything to the discussion but, at the line in question, the argument that needs to be set to Nothing is for supplying an Asynchronous Error handler interface, in the particular API environment, where this may be required. Where it is not required then Nothing is the correct argument to supply - no interface is being given. It is not possible in a scripting language to create the class of object for doing this error handling anyway; because there is no way to do "implements" type feature; so an item of the actual strong type cannot be given.

While we are still at it, AutoIt does not currently have equivalent functions to IsEmpty(), IsNull(), and test (objMy Is Nothing) all of which are regularly required when handling COM and Variant values. If AutoIt has been expanded to use COM then these features are required in the language. I found other posts in this forum from people failing to resolve this same issue.

I am not trying to pick holes, I am trying to find a solution and maybe improve the product as we go. The whole reason I was experimenting with AutoIt was that there are other problems with VBScript which mean it cannot do some things I require - I was interested to see if AutoIt could, because it has inbuilt capability to access some of the Windows API as well as GUI capability making it generally superior to VBScript. I was disappointed when I ran into this issue (type handling) which seemed a bit fundamental to me for a language that specifically uses variants. I am sorry if trying to discuss these limitations is offensive to you.

Link to comment
Share on other sites

Have you tried using?

Global Enum $VT_EMPTY,$VT_NULL,$VT_I2,$VT_I4,$VT_R4,$VT_R8, $VT_CY,$VT_DATE,$VT_BSTR,$VT_DISPATCH, _
    $VT_ERROR, $VT_BOOL, $VT_VARIANT, $VT_UNKNOWN, $VT_UI1 = 17

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

It's not the mentioning that irritates me, it's the way you are doing it. If you can point out legitimate problems with the language, that's fine. As long as you can convince us they are real problems, we will address them. But what I don't like is all the assumptions you're making about how AutoIt works. You don't have the AutoIt source code, we do. Don't speculate how things do work or should work, just tell us what the problem is and prove it's a real problem and leave the rest to us. We don't need the technical talk to the level you are giving it, it's not helping get through the problem.

That being said, you've FINALLY provided enough information, I think. The Default keyword is supposed to handle this... but it doesn't due to an implementation flaw. It is treated as a VARIANT of VT_EMPTY unconditionally. According to the VT_EMPTY documentation, that's the wrong thing to do when the optional argument is an interface. In that case it needs to be VT_ERROR and the value DISP_E_PARAMNOTFOUND. So, now that we know that, we can fix it. Which is just as well because I had a look at the way Default was handled earlier and I don't like it so this is a good excuse to clean up the code completely. It will be fixed in a future version when myself or SvenP find time to work on it.

As for detecting if an expression is a valid COM object, you do know about IsObj(), right?

Link to comment
Share on other sites

Valik,

Sorry but I thought that was exactly what I had done - I have described, in detail, an actual case of real code that I could not implement in AutoIt along with the reasons it did not work.

I had checked this forum and found other people had apparently faced similar problems, whether or not they realised it, but had found no solution. Knowing my limitations I had asked for assistance from any Guru who may have had a solution I had not thought of.

Your last comment re IsObj appears now to show your own ignorance; why do you tell me that - IsObject(Nothing) returns TRUE ie. Nothing IS an object but a special case - the object is unassigned. So testing things to see if they are objects is insufficient. Calling methods or properties of the unassigned object will, of course, die horribly. Objects need to be tested for IsObj(IsObject) sure, but they also may need to be tested for IsNothing (oObj Is Nothing).....whatever. Use of IsObj would not have fixed this code in any way apart from stopping further errors which were not expected to occur anyway. Yeah, I can add IsObj tests to every assignment expanding the code sample but it would not have made any difference to the handling of the actual problem I found. It also would not stop errors in code that will occur if any COM method call returns Nothing.

Any assumptions I may be making are based on your documentation along with my own programming knowledge in several languages. When your documentation says that AutoIt variables are Variant then I expect them to behave like variants, and most of the time, they do - I have drawn your attention to three very specific examples of Variant values which do not work in AutoIt and have requested that this should legitimately be fixed as they are required when using COM.

I welcome your statement that you may implement changes in a future release - I will wait to see that.

PS: VT_EMPTY is not the same as NOTHING so I am not sure that your suggestion for "Default", alone would make my code work. It still does not allow me to create Null, or Nothing values but would pass Empty arguments.

Edited by IMTS
Link to comment
Share on other sites

Valik,

Sorry but I thought that was exactly what I had done - I have described, in detail, an actual case of real code that I could not implement in AutoIt along with the reasons it did not work.

Detail buried away amongst speculation and a thorough explanation of features of another language. And I will point out it took several posts before you ever mentioned the optional argument was in fact an interface. That was the critical piece of information you never gave until post #9, or if you did give it earlier, it's completely lost in the tangle of useless technical information.

I had checked this forum and found other people had apparently faced similar problems, whether or not they realised it, but had found no solution. Knowing my limitations I had asked for assistance from any Guru who may have had a solution I had not thought of.

The manner in which you present it, however, leaves maybe half a dozen people on the forum, at best, who can understand what you want.

Your last comment re IsObj appears now to show your own ignorance;

Brilliant, calling one of the two people on the entire development team with enough experience to fix your problem "ignorant". Remind me why I should ever look at this problem again, please?

why do you tell me that - IsObject(Nothing) returns TRUE ie. Nothing IS an object but a special case - the object is unassigned.

I didn't tell you anything, I asked if you had heard of it.

So testing things to see if they are objects is insufficient. Calling methods or properties of the unassigned object will, of course, die horribly. Objects need to be tested for IsObj(IsObject) sure, but they also may need to be tested for IsNothing (oObj Is Nothing).....whatever.

Enlighten me to the difference between "nothing" and "not a god damned object" because as far as I'm concerned, a Variant is either an object or it's not and whether or not it's a non-empty non-object seems of little consequence.

Use of IsObj would not have fixed this code in any way apart from stopping further errors which were not expected to occur anyway. Yeah, I can add IsObj tests to every assignment expanding the code sample but it would not have made any difference to the handling of the actual problem I found.

Nobody said it would have helped.

It also would not stop errors is code that will occur if any COM method call returns Nothing.

That is your responsibility, not the language. If you don't know if a method is going to return a value or not, you need to go read the documentation and stop writing shitty code.

Any assumptions I may be making are based on your documentation along with my own programming knowledge in several languages.

This isn't other languages. A fact I think you are failing to grasp.

When your documentation says that AutoIt variables are Variant then I expect them to behave like variants, and most of the time, they do - I have drawn your attention to three very specific examples of Variant values which do not work in AutoIt and have requested that this should legitimately be fixed as they are required when using COM.

Require is an awful strong word. You're used to one way or working, AutoIt does not necessarily work that same way. Get used to it. Don't come crying that "required features are missing" because AutoIt works in a different way. You've found a single legitimate problem, as far as I'm concerned.

I welcome your statement that you may implement changes in a future release - I will wait to see that.

PS: VT_EMPTY is not the same as NOTHING so I am not sure that your suggestion for "Default", alone would make my code work. It still does not allow me to create Null, or Nothing values but would pass Empty arguments.

Well, it's quite a bit more work than I originally though and I'm not very inclined to do it anytime soon after being called ignorant. I mean, if I'm ignorant about COM, there's no point in me working on it anyway, because I'm probably too ignorant to do it right. And maybe I really shouldn't bother. Even though I'm about 90% sure it would fix the problem, and it makes absolute complete sense to fix the problem. I mean after all, you the expert here, are sure I'm wrong, and you've already called me ignorant, so I must be wrong.

Edit: Re-structured slightly because of stupid forum quote limit.

Edited by Valik
Link to comment
Share on other sites

To gafrost;

I think you misunderstand the problem posted; we are not trying to create the enumeration values of the variant types, we are trying to create the specific variant values Nothing, Null or Empty and none of these "special" values seems to be possible in AutoIt currently.

Link to comment
Share on other sites

The mapping is as follows, (educated speculation, I have not confirmed this, but I'm not half as ignorant as you may think I am):

VBS  | VARIANT
-----------------
Empty   | VT_EMPTY
Null    | VT_NULL
Nothing | Either VT_EMPTY or VT_ERROR with DISP_E_PARAMNOTFOUND

I don't see where "Empty" and "Nothing" need to be any different. The "Default" keyword should work for both cases, once it's fixed to handle interfaces correctly. There is no support for VT_NULL, nobody has demonstrated a clear need for it so far. Nobody has ever asked for many of the other VT types, either.

Link to comment
Share on other sites

Valik,

Well excuse me...the tone of your first and subsequent replies has be hostile since the start and adding sarcasm (re isObj) is hardly going to improve matters.

It does not matter to me a jot whether you can be bothered to fix this - you suggested at the start that you were unlikely to be bothered to assist as you took exception to my writing style.

You say you did not like my "technical" style and then you respond that it was my comments about "interfaces" which provide the answer - what "joe blogs" is going to use terminology like that - you cannot have it both ways. We would only have got to this point earlier by being "more technical" from the start!!

AutoIt does many things well, I raise support request on an item it does not do well, and you apparently take great offence when I point this out by having a go at me. When I respond you do not like it.

My original posting that AutoIt was not the tool for the job still stands - a big pitty. Would have liked to see it improved but whatever.

Peace.

Link to comment
Share on other sites

Valik,

Glad to hear you are not ignorant - we are out of sync on replies Last Post by me was in response to your step-by-step comments.

This is in reply to your other post re Default VBS VT_Types.

If no request for Null then I take it there has not been much call for use of AutoIt with databases, particularly with ADO. Null is very useful then.

By the way: you say I did not get to the point until Post #9 but I mentioned in my second post (post #3) that the variable was an interface. You may not like my writing style but I really don't see how we could have got to the point any quicker.

Link to comment
Share on other sites

Valik,

Well excuse me...the tone of your first and subsequent replies has be hostile since the start and adding sarcasm (re isObj) is hardly going to improve matters.

Sarcasm? I wasn't being sarcastic.

It does not matter to me a jot whether you can be bothered to fix this - you suggested at the start that you were unlikely to be bothered to assist as you took exception to my writing style.

That's because your style leaves out the most important information. Once you finally provided that critical piece of information, I knew instantly what the problem was.

You say you did not like my "technical" style and then you respond that it was my comments about "interfaces" which provide the answer - what "joe blogs" is going to use terminology like that - you cannot have it both ways. We would only have got to this point earlier by being "more technical" from the start!!

I think there's a difference between technical jargon and basic COM knowledge. Had you provided any sort of clue that the argument you didn't want to specify was expecting a COM object, this would have been simple. That's nothing more than basic COM knowledge. On the other hand, I have to wade through loads of crap about nulls and memory and "nothing", none of which is really relevant in AutoIt.

AutoIt does many things well, I raise support request on an item it does not do well, and you apparently take great offence when I point this out by having a go at me. When I respond you do not like it.

You raise a support request telling us in great detail how something's wrong, how it should work, how you would make it work but you don't provide enough data to demonstrate what is wrong, at least, not without a couple followups to extract the information. Then you do provide enough information so that somebody realizes the problem, admits it. You promptly call them ignorant and subsequently say the proposed fix won't work.

My original posting that AutoIt was not the tool for the job still stands - a big pitty. Would have liked to see it improved but whatever.

Your own ignorance is the reason it isn't the right tool, then. Okay, I admit, you found a problem, but that can be fixed. However, a lot of your problems seems to stem from you not understanding how COM works. So I would say that the only reason AutoIt is not the right tool for you seems to stem from your own incompetence in working with COM. I haven't seen any big issues from Locodarwin, big_daddy or DaleHohm and they've used COM extensively. I'm inclined to think that for the most part, barring a few obscure issues like what you've found, AutoIt's COM interaction is pretty solid. It's not half as flawed as you seem to be trying to make it out to be.

Peace.

Is an illusion.

Edit: Regarding post #3, I just re-read it. Yes, you mention an interface. But you mention you want to create a "nothing" object. You never mentioned, and it's not clear at all from that post, that the function argument is an interface. You're so focussed on the "nothing" keyword that you leave out important information. You were/are stuck on the notion that "nothing" is a tangible concept. It's not, it's an abstraction. Just like "Default" is an abstraction. It's just that Default is missing one of the things it needs to abstract.

Edited by Valik
Link to comment
Share on other sites

That's because your style leaves out the most important information. Once you finally provided that critical piece of information, I knew instantly what the problem was.

And how are we supposed to know what information is important to you - that is why we ask for help?

Your own ignorance is the reason it isn't the right tool, then.

No, this was purely an experiment which failed - a strongly typed language would be used with the API I am interfacing with, normally. I do use this API all the time without issue in such an environment. Some bits can also be called by VBScript. Virtually none can be called from AutoIt, currently, because of the flaw I found which means that critical API objects cannot be created. This is not my ignorance it is the limitation of the language. The particular API would usually only be called by C/C++ or VB - using AutoIt was just a challenge for me to play with.

Okay, I admit, you found a problem, but that can be fixed.

Good - that's the idea.

However, a lot of your problems seems to stem from you not understanding how COM works. So I would say that the only reason AutoIt is not the right tool for you seems to stem from your own incompetence in working with COM.

How is the problem I have raised got anything to do with my code exactly - until you fix AutoIt it simply will not work with the API I was calling and that has nothing to do with my competence at all. You take exception to me calling you "ignorant" despite the fact you have been doing this to me directly and indirectly.

It's not half as flawed as you seem to be trying to make it out to be.

Not trying to - I asked a simple question about how to create a specific variable value: "Nothing", this then additionally spawned the fact that I could not create the two other specific cases. These facts have nothing to do with my competence either - the current implementation of AutoIt does not let me. You say "so what" this is how AutoIt works - fair enough so AutoIt is not the tool for the job.

The API I was experimenting with calling was never intended to be used with something like AutoIt so it perfectly valid to say "AutoIt is not the tool for the job". This is not a reflection of my competence but may be a reflection on the design of the original API that it uses techniques which are very dependent upon the use of strongly typed languages to program with.

I can accomplish many things with VBScript and this API - I wanted to see if I could accomplish more using AutoIt. The answer turns out to me NO and that has nothing to do with my competence at using either AutoIt or COM.

You have no idea what my competence level is and I do not believe that anything I have posted here is actually incorrect, apart from possibly calling you "ignorant", but then you have certainly done the same to me. Do you really think I do not know what IsObj func is for and what was the relevance of that comment anyway?

Link to comment
Share on other sites

And how are we supposed to know what information is important to you - that is why we ask for help?

Well, it wouldn't have been too much to ask of you to provide a sample script, example of the interface since it's not public or common and a list of things you've tried. You eventually did give all this information, slowly. What you did not need to give was all the information on VBScript.

No, this was purely an experiment which failed - a strongly typed language would be used with the API I am interfacing with, normally. I do use this API all the time without issue in such an environment. Some bits can also be called by VBScript. Virtually none can be called from AutoIt, currently, because of the flaw I found which means that critical API objects cannot be created. This is not my ignorance it is the limitation of the language. The particular API would usually only be called by C/C++ or VB - using AutoIt was just a challenge for me to play with.

Couple things. First, if it provides IDispatch, it's meant to be called from any language, typed or not. I don't see what typing has to do with COM and using it, though. COM is about interfaces, not types. That's why COM uses a VARIANT, after all. Second, calling a "bug" a "limitation of the language" is a misnomer. It's not a limitation of the language, it's a bug in the language, and there is a difference as far as I'm concerned. A limitation is unlikely to be fixed or is intentional, a bug typically is not. That's an important distinction.

How is the problem I have raised got anything to do with my code exactly - until you fix AutoIt it simply will not work with the API I was calling and that has nothing to do with my competence at all.

Well, you seem to be going on and on about so-called types AutoIt doesn't support which nobody else has expressed a strong desire for needing.

You take exception to me calling you "ignorant" despite the fact you have been doing this to me directly and indirectly.

Not at all, calling me ignorant is one of the nice things I've been called. I just find it extremely amusing that you call me ignorant when I'm one of only two people who can fix your problem. It's not really that you're calling me ignorant, it's that you're calling a developer who knows about COM ignorant.

Not trying to - I asked a simple question about how to create a specific variable value: "Nothing", this then additionally spawned the fact that I could not create the two other specific cases. These facts have nothing to do with my competence either - the current implementation of AutoIt does not let me. You say "so what" this is how AutoIt works - fair enough so AutoIt is not the tool for the job.

This is the crux of the problem with you. You want to create these things but you don't know what they are and as a result you are convinced you must have them. Meanwhile, everybody else has seemingly accepted that AutoIt is not VBScript and has learned how to use COM in AutoIt as opposed to complaining about how COM in AutoIt is not exactly like it is in VBScript.

The API I was experimenting with calling was never intended to be used with something like AutoIt so it perfectly valid to say "AutoIt is not the tool for the job".

Does it implement IDispatch? Yes, I know it does without seeing it or you wouldn't be able to use it in VBScript. So yes, it was intended to be used with a language like AutoIt.

I can accomplish many things with VBScript and this API - I wanted to see if I could accomplish more using AutoIt. The answer turns out to me NO and that has nothing to do with my competence at using either AutoIt or COM.

Sorry, but yes it does. I guarantee I can do more with AutoIt with or without COM than you can do with VBScript using this API. With proper documentation and patience, I can do anything with this API that I can do in C++.

You have no idea what my competence level is and I do not believe that anything I have posted here is actually incorrect, apart from possibly calling you "ignorant", but then you have certainly done the same to me. Do you really think I do not know what IsObj func is for and what was the relevance of that comment anyway?

Again, you are stuck on VBScript concepts. To check if a variable is a COM object, we use IsObj() in AutoIt. We don't use those other functions you keep bringing up because we don't use those types you keep bringing up. AutoIt is not VBScript. Forget what you know about VBScript if you are going to use AutoIt. They aren't the same thing. Figure out what you want to accomplish and figure out if it's even necessary in AutoIt before you start complain it's not the right tool because it doesn't have certain features.
Link to comment
Share on other sites

  • Developers

For sheer entertainment value, this has been one of the better threads.

Don't agree... I think its a waste of time to argue about it for this length.

Sounds to me both want to explain/argue they are right ...

I am not judging nor taking sites for the simple reason I don't care about right or wrong, but do have the impression the OP revealed a valid issue which is important for improving AutoIt3.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...