Jump to content

Search string and find value, assign value to variable


dufran3
 Share

Recommended Posts

In my script I'm using, I am currently assigning variables in the script. I am assigning version numbers. Like this:

GLOBAL $AcrobatVer = '9.3.4'
GLOBAL $AdobeFlashVer   = '10.1'
GLOBAL $iTunesVer  = '10.0'
GLOBAL $JavaVersion = '6.21'

etc...

I am then displaying this information in a GUI interface:

Dim $aDesktop[8][4] = [ _
                ['Adobe Acrobat Reader ' & $AcrobatVer ,'_InstallAcrobat','0','0'], _
                ['Adobe Flash Player ' & $AdobeFlashVer,'_InstallFlashPlayer','0','0'], _
                ['iTunes and Quicktime ' & $iTunesVer, '_InstalliTunes','0','0'], _
                ['Java ' & $JavaVersion,'_InstallJava','0','0'] _
           ]

So everytime a version is changed, I have to go rebuild the script and re-compile and distribute. I was thinking I could maintain some type of text file. Maybe formatted to read. So the script, when compiled, will look to the text file, and I will only need to change the text file version w/out having to re-distribute the compiled .exe....I hope that makes sense.

Maybe a text file formatted like this...

[Adobe Acrobat Reader]

Version = "9.3.4"

[Adobe Flash Player]

Version = "10.1"

etc...

anyone know of a good way to read this text file and assign the variables based on the version number in that text file?

arrggg

Link to comment
Share on other sites

This is what I have come up w/ so far....

;Read in Versions
    $VersionFile = FileOpen(@ScriptDir & '\Version.txt',0)
    For $i = 0 to 14 ;number of lines in file, not sure how to determine this automatically
        $VersionFileRead = FileReadLine($VersionFile)
        Select
            Case If StringInStr($VersionFileRead, 'Adobe') Then
                $AdobeVersion
        MsgBox(0,'',$VersionFileRead)
    Next
Link to comment
Share on other sites

Thanks a ton man, I was trying to us a loop, with StrinInStr and Case Select...it was a mess, you made this wayyyy easier! THx! I will share what I have now...

;Read in Software Versions
        $VersionFileRead = @ScriptDir & '\Version.ini'
        ;Adobe Acrobat Reader
        GLOBAL $AcrobatVer = IniRead($VersionFileRead,'Adobe Acrobat Reader','Version','Not Found')
        GLOBAL $AcrobatFileName = IniRead($VersionFileRead,'Adobe Acrobat Reader','Filename','Not Found')
        ;Adobe Flash Player
        GLOBAL $AdobeFlashVer = IniRead($VersionFileRead,'Adobe Flash Player','Version','Not Found')
        GLOBAL $FlashFileName = IniRead($VersionFileRead,'Adobe Flash Player','FileName','Not Found')
        ;Itunes and QuickTime
        GLOBAL $iTunesVer = IniRead($VersionFileRead,'iTunes','Version','Not Found')
        GLOBAL $iTunesFileName = IniRead($VersionFileRead,'iTunes','FileName1','Not Found')
        GLOBAL $QuickTimeFileName = IniRead($VersionFileRead,'iTunes','FileName2','Not Found')
        GLOBAL $AppleAppSupportFileName = IniRead($VersionFileRead,'iTunes','FileName3','Not Found')
        GLOBAL $MobileDeviceFileName = IniRead($VersionFileRead,'iTunes','FileName4','Not Found')
        GLOBAL $SoftwareUpdateFileName = IniRead($VersionFileRead,'iTunes','FileName5','Not Found')
        GLOBAL $BonjourFileName = IniRead($VersionFileRead,'iTunes','FileName6','Not Found')
        GLOBAL $MobileMeFileName = IniRead($VersionFileRead,'iTunes','FileName7','Not Found')
        ;Java
        GLOBAL $JavaVersion = IniRead($VersionFileRead,'Java','Version','Not Found')
        GLOBAL $JavaFileName = IniRead($VersionFileRead,'Java','FileName','Not Found')
        ;Firefox
        GLOBAL $FirefoxVer = IniRead($VersionFileRead,'Firefox','Version','Not Found')
        GLOBAL $FirefoxFileName = IniRead($VersionFileRead,'Firefox','Filename','Not Found')
        ;Office
        GLOBAL $OfficeVer = IniRead($VersionFileRead,'Office','Version','Not Found')
        GLOBAL $OfficeFileName = IniRead($VersionFileRead,'Office','Filename','Not Found')
        GLOBAL $OfficeInstallSource = IniRead($VersionFileRead,'Office','Path','Not Found')
        ;VLC
        GLOBAL $VLCVer = IniRead($VersionFileRead,'VLC','Version','Not Found')
        ;Domain Tools
        GLOBAL $DomainToolsSource = IniRead($VersionFileRead, 'Domain Tools','Path','Not Found')
        GLOBAL $DomainToolsTarget = IniRead($VersionFileRead, 'Domain Tools','Target','Not Found')

Textfile looks like this

[Adobe Acrobat Reader]

Version=9.3.4

FileName=AdbReader.exe

[Adobe Flash Player]

Version=10.1

FileName=flashplayer.exe

[iTunes]

Version=10.0

Filename1=iTunesSetup.exe

Filename2=QuickTimeInstaller.exe

Filename3=AppleApplicationSupport.msi

Filename4=ApplieMObileDeviceSupport.msi

Filename5=AppleSoftwareUpdate.msi

Filename6=Bonjour.msi

Filename7=Mobileme.msi

[Java]

Version=6.21

Filename=

[Firefox]

Version=3.6.9

Filename=

[Office]

Version=2007 Pro Plus

FileName=setup.exe

Path=\\Installers\Office_2007_Pro_Plus\

[VLC]

Version=1.1.4

Filename=

[Domain Tools]

Version=

Path=\\146.187.7.66\Domain Tools

Target=c:\temp\RDT\Domain Tools\

edit: on a side note, do all those GLOBAL declarations make my script run slower? I was thinking I could not make them global, and maybe pass them into each function...not sure

Edited by dufran3
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...