Jump to content

Help Please!


aldakrys
 Share

Recommended Posts

Hi,

If someone can help me it would be much appreciated.

Here is what I’m trying to do:

I have 2 ini files: “ext.ini” and “trg.ini” each one has: a section; multiple keys with a different value (from 1=32345, 2=42321 … to 3000=342214 <ext.ini>) and (from 1=54587, 2=45367 … to 3000=64332 <trg.ini>). Now I want to take, in turn, the first key in the “ext.ini” and compare it with all the keys in “tgr.ini” then the second, an so on.

What I’ve done so far:

I have created 2 .au3 files “ext.au3” and “tgr.ini”:

$ext1 = IniRead( "ext.ini", "ext", "1", "")

$ext2 = IniRead( "ext.ini", "ext", "2", "")

$ext3 = IniRead( "ext.ini", "ext", "3", "")

$ext4 = IniRead( "ext.ini", "ext", "4", "")

……………………………………………………………

$ext3000 = IniRead( "ext.ini", "ext", "3000", "")

And

$trg1 = IniRead( "trg.ini", "trg", "1", "")

$trg2 = IniRead( "trg.ini", "trg", "2", "")

$trg3 = IniRead( "trg.ini", "trg", "3", "")

$trg4 = IniRead( "trg.ini", "trg", "4", "")

……………………………………………………………

$trg3000 = IniRead( "trg.ini", "trg", "3000", "")

And a 3-rd .au3 file called “run.au3”:

#include "ext.au3"

#include "trg.au3"

Now what should I use to compare (here is where I’ve got stuck)

$ext1 = $trg1 to $tgr3000

……………………

and then

IniWrite("new.ini", "new", "1", $ext1)

IniWrite("new.ini", "new", "2", $ext2)

IniWrite("new.ini", "new", "3000", $ext3000) – that is, if it finds one (or several) that doesn’t match.

Thank you very much for your help.

Link to comment
Share on other sites

... some knowledge about arrays will make your life much easier ...

Read about IniReadSection (the example there will give you an idea about For - Next ... you need to use that later in your script)

Once you have 2 arrays filled up from your ini files, you need to nest 2x For-Next loops to do the comparison; I'll give you a code sample:

$ext = IniReadSection("my ini", "my section")
$trg = IniReadSection("my ini", "my section")

For $i = 1 To $ext[0][0]
    $match = 0                                  ;match found or not
    For $j = 1 To $trg[0][0]
        If $ext[$i][1] == $trg[$j][1] Then
            $match = 1                          ;match found
            ExitLoop                            ;go to next $ext
        Else
            ContinueLoop                        ;go to next $trg
        EndIf
    Next
    If $match = 0 Then IniWrite("my ini", "new", $i, $ext[$i][1])
Next

Good luck,

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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