Jump to content
Sign in to follow this  
NoProgrammer

endIf errors

Recommended Posts

NoProgrammer

I am trying to convert a script I downloaded to v3 (I am new to AutoIt and don't have any other aut scripts, also thought it would help me learn how to write scripts). I used the automatic converter but it threw some errors that I'm trying to fix manually.1)I inserted the Path line after the two Fatal Error lines manually. Is this correct? 2)I'm getting the following errors. Can someone help me correct them?

C:\ABTestzz.au3(38,5) : ERROR: missing EndIf.
    wend
~~~~^
C:\ABTestzz.au3(36,37) : REF: missing EndIf.
    if NOT __cmp($LAST, $FIRST) then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\ABTestzz.au3(39,1) : ERROR: syntax error
wend
^
C:\ABTestzz.au3(36,31) : ERROR: __cmp(): undefined function.
    if NOT __cmp($LAST, $FIRST)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\ABTestzz.au3 - 3 error(s), 0 warning(s)

;   V2.64 to V3.0.100 (Version 1.0.6)
;   Converted with AutoItV2toV3 [Version 1.0.6]
;   (C) Copyright 2004 J-Paul Mesnage.

;       Global variables generation
global $EPISODE
;

; ------------------------------------------
; ----- user settings (case sensitive) -----
; ------------------------------------------
;*** FATAL ERROR Impossible to Convert : SetEnv, PATH C:\\
;*** FATAL ERROR Missing Parameter conversion impossible : SetEnv, PATH C:\\
$PATH = "C:\\"
$FILENAME = 'AVSMasstest'
$FIRST = 1
$LAST = 4

while (1)   ; START : beginning of loop OR Func START ()

    Run ( 'notepad.exe ' & $PATH & $FILENAME & $FIRST & '.avs' )
    WinWaitActive ( $FILENAME )
    Send ( '{DOWN 2}{ENTER}{UP}' )

; ----------------------------------------------
; ----- put your line to be inserted below -----
; ----------------------------------------------
    Send ( 'undot().whatever.whatever' )

    Send ( '^S' )
    Send ( '{ALT}{UP 2}{ENTER}' )
    WinWaitActive ( 'Notepad' )
    Send ( '{ENTER}' )

    $NUMBER = StringRight( $EPISODE, 2 )
    if NOT __cmp($LAST, $FIRST) then
        $FIRST = $FIRST + 1
    wend        ; START
wend        ; START

endif   ; END
Exit 


; Epilogue  Extra Functions needed for Compatibility execution
;           take care of possible redefinition if you are converting  an include file
;
func __cmp ($_1, $_2); to handle Case sensitive comparison
global $__strcase
if $__strcase = 0 then
    return ($_1 = $_2)
else
    return ($_1 == $_2)
endif
endfunc
;
; End Epilogue

Share this post


Link to post
Share on other sites
MrSpacely

Can you explain what the purpose of the script is, it would help a lot.

Because there are much quicker ways often.

The old autoit 2 script had less possiblities so you needed to code lots of things wich can be done much simpler and quicker thats why I'd like to know what the script is supposed to do

Share this post


Link to post
Share on other sites
NoProgrammer

Can you explain what the purpose of the script is, it would help a lot.

Because there are much quicker ways often.

The old autoit 2 script had less possiblities so you needed to code lots of things wich can be done much simpler and quicker thats why I'd like to know what the script is supposed to do

The purpose of the script is to take any avs file in a directory (in this case File =AVSMassTest.avs and directory =C:\) and add a line to each at a given line number. In this case it should add the line undot().whatever.whatever

to AVSMassTest1.avs, AVSMassTest2.avs and AVSMassTest3.avs.

Share this post


Link to post
Share on other sites
MHz

Just a quick fix. :P

; Temporary Script  TEMP_ziw.au3

;   V2.64 to V3.0.100 (Version 1.0.6)
;   Converted with AutoItV2toV3 [Version 1.0.6]
;   (C) Copyright 2004 J-Paul Mesnage.

;       Global variables generation
Global $EPISODE
;

; ------------------------------------------
; ----- user settings (case sensitive) -----
; ------------------------------------------
;*** FATAL ERROR Impossible to Convert : SetEnv, PATH C:\\
;*** FATAL ERROR Missing Parameter conversion impossible : SetEnv, PATH C:\\
$PATH = "C:\\"
$FILENAME = 'AVSMasstest'
$FIRST = 1
$LAST = 4

While (1)   ; START : beginning of loop OR Func START ()
    
    Run('notepad.exe ' & $PATH & $FILENAME & $FIRST & '.avs')
    WinWaitActive($FILENAME)
    Send('{DOWN 2}{ENTER}{UP}')
    
; ----------------------------------------------
; ----- put your line to be inserted below -----
; ----------------------------------------------
    Send('undot().whatever.whatever')
    
    Send('^S')
    Send('{ALT}{UP 2}{ENTER}')
    WinWaitActive('Notepad')
    Send('{ENTER}')
    
    $NUMBER = StringRight($EPISODE, 2)
    If Not __cmp($LAST, $FIRST) Then
        $FIRST = $FIRST + 1
    EndIf      ; START
WEnd       ; START

; END
Exit 


; Epilogue  Extra Functions needed for Compatibility execution
;            take care of possible redefinition if you are converting  an include file
;
Func __cmp($_1, $_2); to handle Case sensitive comparison
    Global $__strcase
    If $__strcase = 0 Then
        return ($_1 = $_2)
    Else
        return ($_1 == $_2)
    EndIf
EndFunc
;
; End Epilogue

Share this post


Link to post
Share on other sites
NoProgrammer

Thanks MHz Your fix seems to hang up at

WinWaitActive($FILENAME)

I got it to go past that by changing to a sleep command (whioch also caused big problems later), It also seems to hang at this line:

Send('^S')

Share this post


Link to post
Share on other sites
LxP

Welcome to the forums!

Could you please consider posting the original .AUT file for those of us who understand AutoIt v2 code? It seems that the $Episode variable is being used before ever being set.

Share this post


Link to post
Share on other sites
NoProgrammer

Welcome to the forums!

Could you please consider posting the original .AUT file for those of us who understand AutoIt v2 code? It seems that the $Episode variable is being used before ever being set.

OK here's the link to the post where I found the script:

original post on Doom9 by LB

Here is just the code:

; ------------------------------------------
; ----- user settings (case sensitive) -----
; ------------------------------------------
SetEnv, PATH, C:\\
SetEnv, FILENAME, ddog
SetEnv, FIRST, 1
SetEnv, LAST, 50

START:

Run, notepad.exe %PATH%%FILENAME%%FIRST%.avs
WinWaitActive, %FILENAME%
Send, {DOWN 2}{ENTER}{UP}

; ----------------------------------------------
; ----- put your line to be inserted below -----
; ----------------------------------------------
Send, undot().whatever.whatever

Send, ^S
Send, {ALT}{UP 2}{ENTER}
WinWaitActive, Notepad
Send, {ENTER}

StringRight, NUMBER, EPISODE, 2
IfEqual, LAST, %FIRST%, Goto, END
EnvAdd, FIRST, 1
Goto, START

END:
Exit

Share this post


Link to post
Share on other sites
LxP

This script appears to insert a specific line underneath the first two lines of a set of files. This can be done without opening Notepad.

Perhaps this will suit your needs:

Local $AddLine = 'undot().whatever.whatever'

Local $Path = 'C:\'
Local $FileBase = 'ddog'
Local $First = 1
Local $Last = 4

#Include <File.au3>
Local $FileData
For $I = $First To $Last
    Local $FilePath = $Path & $FileBase & $I & '.avs'
    If Not _FileReadToArray($FilePath, $FileData) Then
        MsgBox(0x30, 'Error', 'Could not read file:' & @LF & $FilePath)
    Else
    ; Insert a new third line
        If $FileData[0] < 2 Then
            MsgBox(0x30, 'Warning', 'No third line in file:' & @LF & $FilePath)
        Else
            $FileData[2] = $FileData[2] & @CRLF & $AddLine
        ; Write the file out again
            Local $Handle = FileOpen($FilePath, 2)
            If $Handle = -1 Then
                MsgBox(0x30, 'Error', 'Could not write to:' & @LF & $FilePath)
            Else
                For $J = 1 To $FileData[0]
                    FileWriteLine($Handle, $FileData[$J])
                Next
                FileClose($Handle)
            EndIf
        EndIf
    EndIf
Next

Share this post


Link to post
Share on other sites
NoProgrammer

Thanks LxP

I can't believe how fast that executes and your writing style is so clear that even a newbie like me could figure out how to add extra lines to the insertion. :P

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.