Sign in to follow this  
Followers 0
Steve Lovell

Exit Values

4 posts in this topic

I'm using AutoIt to create a simple executable that I'm calling from a Y!WE widget.

I want the script to do one of two things depending on the number of parameters it's passed.

If no parameters are passed it searches two registry locations for an instance of "FirstDisplay" and returns a 1 or a 2 if it finds the entry in those locations.

If parameters are passed, the first is either a 1 or a 2 and the second is the name of registry key to delete (from the same location as "FirstDisplay").

The deletion part works okay, but it seems that however I set up the Exit command it returns 0.

Here's one version of my script:

#include <Array.au3>

$regArray = _ArrayCreate( _
                        "HKEY_CURRENT_USER\Software\Yahoo\WidgetEngine\Widgets\", _
                        "HKEY_CURRENT_USER\Software\Pixoria\Konfabulator\Widgets\" _
                        )

Dim $ThisWidget
$ThisWidget = "FirstDisplay"

Dim $RegIndex
$RegIndex = -1

if $CmdLine[0]<2 Then LookForSelf()
if $CmdLine[0]=2 Then DeleteEntry()
if $CmdLine[0]>2 Then Exit (0)

Func LookForSelf()
    Dim $RegCheck
    $RegIndex = 0

    For $RegCheck = 0 to _ArrayMaxIndex($regArray)
        if RegEnumKey($regArray[$RegCheck] & $ThisWidget,1) <> "" Then $RegIndex = $RegCheck +1  
    Next    
EndFunc

Func DeleteEntry()
    Dim $ToDelete
    $ToDelete = $regArray[$CmdLine[1]-1] & $CmdLine[2]
    if RegEnumKey($ToDelete,1)="" Then
        MsgBox(0,$ThisWidget,"Sorry, " & $CmdLine[2] & " not found in registry")
    Else
        RegDelete($ToDelete)
        MsgBox(0,$ThisWidget,"Registry entries for " & $CmdLine[2] & " have been removed")
    EndIf
EndFunc

MsgBox(0,"",$RegIndex)
Exit $RegIndex

If I run the script from SciTE, ie passing no parameters, then the message box at the end gives "1" but the exit code is still 0. Any ideas?

Share this post


Link to post
Share on other sites



Very strange. I am using Scite4Autoit3 as can be downloaded from here.

I run this

$RegIndex = 1
MsgBox(0,"",$RegIndex)
Exit $RegIndex

and get this output

>"C:\Program Files\Autoit3\SciTe\..\Beta\autoit3.exe" /ErrorStdOut "C:\Program Files\AutoIt3\SciTE\Temp\2006.11.27_tdp.au3"

>Exit code: 1 Time: 1.760

Exit code of 1, so I do not understand the result that you receive. Are you up to date with your Scite version?

Share this post


Link to post
Share on other sites

Very strange. I am using Scite4Autoit3 as can be downloaded from here.

I run this

$RegIndex = 1
MsgBox(0,"",$RegIndex)
Exit $RegIndex
oÝ÷ Ù©Ýëm+(ºÚn´LbµÊzõ²¢z-ºw^®ËZÛaz·¬º[m«r¢êÞqè¯x
ÞÊ®¦Új×°Ør¢êÒr+^½êìÿªê-xúèm¦åÉ©Ò¶¸§+,¹äëÊë"®¶­sbWBçVÖ&W"b33cµ&VtæFW

;)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for your speedy replies ...

Tried the Exit Number($RegIndex) thing, but with no success.

I also tried the three line script and that had the same result as my longer one.

But since that seemed to indicate problems with my installation I downloaded and installed the latest AutoIt and SciTE packages and now all is working as would be expected.

It was rather weird though.

Thanks again,

Steve

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