Jump to content

Endif Statement With No Mathing If Expression!?


Recommended Posts

Hello,

im working on this script:

#include "config2.ini"


;## Office 2000_______________________________________
IF $program['office2000'] = 0 THEN
    RunWait("Office 2000/Office2000_CD.exe")
    $program['office2000'] = 1
ENDIF

;## [X] Visio 2000____________________________________
IF $program['visio2000'] = 0 THEN
    RunWait("Visio 2000\visio2000.exe")
    $program['office2000'] = 1
ENDIF


;## Projekt 2000______________________________________
IF $program['projekt2000'] = 0 THEN
    RunWait("Projekt 2000\projekt2000.exe")
    $program['projekt2000'] = 1
ENDIF

In the config2.ini is an Array declared, this form:

DIM $program[19]

$program['office2000'] = 1

$program['visio2000'] = 1

$program['projekt2000'] = 1

On the end of my script, it should write a new config2.ini. So, if I run the Office 2000 Setup, it finished, and i must reboot - i should start the script again and it continues with the installation after office 2000.

But i get following error:

ENDIF

Error: "EndIf" statement with no matching "If" statement.

What i did wrong?

Attention! English noob ^^

Link to comment
Share on other sites

You need to use integers for array subscripts. You may need to use variables to replace the strings that you are using.

$office2000 = 1
IF $program[$office2000] = 0 THEN
    RunWait("Office 2000/Office2000_CD.exe")
    $program[$office2000] = 1
ENDIF
Link to comment
Share on other sites

Grml, didnt work?! :)

#include "config.ini"
#include "config2.ini"


;## Office 2000_______________________________________
IF $program[$office2000] = 0 THEN
    RunWait("Office 2000/Office2000_CD.exe")
    $program[$office2000] = 1
ENDIF

;## [X] Visio 2000____________________________________
IF $program[$visio2000] = 0 THEN
    RunWait("Visio 2000\visio2000.exe")
    $program[$visio2000] = 1
ENDIF


;## Projekt 2000______________________________________
IF $program[$projekt2000] = 0 THEN
    RunWait("Projekt 2000\projekt2000.exe")
    $program[$projekt2000] = 1
ENDIF

config.ini:

$office2000  = 0
$visio2000   = 1
$projekt2000 = 2

config2.ini

DIM $program[18]
$program[$office2000]  = 1
$program[$visio2000]   = 1
$program[$projekt2000] = 1

(There are more Programs, so dont wonder if u see only 3 programs, but i declare a 18er Array... )

I get the same Error! Why?! :mellow:

Edited by neo van matix

Attention! English noob ^^

Link to comment
Share on other sites

  • Moderators

HMMM... are you trying to run your script from an ini?

Edit:

Let me reitterate: Are you litterally trying to run your script from an .ini rather than an .au3? Do you know what an .ini is and how to make one?

Edit2:

This is how I understand what you want to do:

1. Create an ini... Example of how you could make your ini:

[Programs]Office 2000\Office2000_CD.exe = 1

Visio 2000\visio2000.exe = 1

Projekt 2000\projekt2000.exe = 1

2. Check to see if it has been run, and if it hasn't run it (look up inireadsection in the help file to understand what I did):
Local $INI_LOCATION = @DesktopDir & '\test.ini'
Local $PROGRAM = IniReadSection($INI_LOCATION, 'Programs')

For $i_Count = 1 To $PROGRAM[0][0]
    If $PROGRAM[$i_Count][1] = 1 Then
        RunWait($PROGRAM[$i_Count][0])
        IniWrite($INI_LOCATION, 'Programs', $PROGRAM[$i_Count][0], 0)
    EndIf
Next
Untested because I don't have those programs, but if the .exe locations are correct that you've provided then it should be fine. Edited by SmOke_N

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.

Link to comment
Share on other sites

Uhm o.O

I only want to include the inis into my au3 - maybe... *gg*

I should change the ending ini into au3, lets see what happens.. *g*

Edit: Nothing :)

I changed the ending, but i still get the error :/

#include "config.au3"

#include "config2.au3"

Edit2: Grml, i hate english.. *gg* Okay, again:

In a file (like config.ini or au3) i've some Values for some Vars, like $office2000 = 0.

0 for not-installed, 1 for installed.

In my script, i include this file. Then i check, if these programs are installed (1). If not (0), it should start the installer.

Then i set the actual state - $office2000 = 1 (was installed).

On the end of my script, i write a new config-file, which includes the actual states of each program.

So, if i start the script again, $office2000 = 1, also installed... the script continues with the next program.

I've a seperate config file, because i will add a reboot-command after the installation of each program - the script is in the AutoStart folder, so on reboot it starts automaticly and continues with the installation.

Understoodable? Or Understandable? ... *g*

Edited by neo van matix

Attention! English noob ^^

Link to comment
Share on other sites

Uhm o.O

I only want to include the inis into my au3 - maybe... *gg*

I should change the ending ini into au3, lets see what happens.. *g*

Edit: Nothing :mellow:

I changed the ending, but i still get the error :/

#include "config.au3"

#include "config2.au3"

Edit2: Grml, i hate english.. *gg* Okay, again:

In a file (like config.ini or au3) i've some Values for some Vars, like $office2000 = 0.

0 for not-installed, 1 for installed.

In my script, i include this file. Then i check, if these programs are installed (1). If not (0), it should start the installer.

Then i set the actual state - $office2000 = 1 (was installed).

On the end of my script, i write a new config-file, which includes the actual states of each program.

So, if i start the script again, $office2000 = 1, also installed... the script continues with the next program.

I've a seperate config file, because i will add a reboot-command after the installation of each program - the script is in the AutoStart folder, so on reboot it starts automaticly and continues with the installation.

Understoodable? Or Understandable? ... *g*

You don't normally include an .ini file at all. It is read and used via AutoIT commands like IniRead() and IniWrite(). The #include command would only be appropriate if the contents of the files were valid AutoIT commands. Your $office2000 = 0 command would work and the $office2000 variable would be valid while the program was running, but nothing is written to the included file (actually, it sounds like you are writing it to a different file). So next time the program is run $office2000 will still be 0.

Perhaps what you meant to do was read the .ini file, check the value of the Office2000 key, if it's 0 then run the install, then change the key value to 1. The .ini file would not be included, it would just be accessed as an external file by the IniRead() and IniWrit() functions.

Does that make it more clear? :)

Adding some code adapted from SmOke_N's earlier post:

First, the Programs.ini file to control the installs. This file tracks if the files are installed or not and gives the required install info, with a seperate section for each program. It can be edited to add/delete programs without changing the AutoIT script:

; Programs.ini
; Each program is a separate section.
; Installed = 0 for No, or 1 for Yes
; InstallExe = Install command, with full path to the executable

[Office2000]
Installed = 0
InstallExe = \Office2000\setup.exe /q

[Visio2000]
Installed = 0
InstallExe = \Visio2000\setup.exe /q

[Projekt2000]
Installed = 0
InstallExe = \Projekt2000\setup.exe /q

Then the AutoIT script that uses the ini file (without including it):

$INI_File = @ScriptDir & '\Programs.ini'
$PROGRAMS = IniReadSectionNames($INI_File)

For $P = 1 To $PROGRAMS[0]
    If IniRead($INI_File, $PROGRAMS[$P], "Installed", "0") = 0 Then
        $InstallExe = IniRead($INI_File, $PROGRAMS[$P], "InstallExe", "")
        RunWait(@ComSpec & '/c "' & $InstallExe & '"', @TempDir, @SW_MINIMIZE)
        IniWrite($INI_File, $PROGRAMS[$P], "Installed", "1")
    EndIf
Next

The .ini file get updated to show that install has already been run. Since the .ini file is external to the script, a different one can located on each computer, if required.

Hope that helps! :)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hello, thanks, i understand how your Code works.

But, although... i cant understand, why i get an error in my If-Statement.

I tried to include "config.au3" in place of "config.ini" - doesnt work.

And, i dont know, that autoit has own functions to handle *.ini's... my fault :)

Attention! English noob ^^

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...