Jump to content

Read key with no equal sign


Recommended Posts

Is it possible to read a section that has a key with no value?

For Example

;
; Sample combination printer INF for NT 4.0 and Win95.
; 
; (This inf should work for both OS's, but not all sections apply to both.)
;
;

[Version]
Signature="$Windows NT$"
Provider=%Company%
LayoutFile=printer.inf
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer

;
; Manufacturer Sections
;
; This section lists all of the manufacturers that we will
; display in the Dialog box.
;
[Manufacturer]
"Konica"

;
; Model Sections 
;
; These sections correspond with an entry listed in the
; [Manufacturer] section above. The models will be displayed in the order
; that they appear here.
;
[Konica]
"Konica IP-431 PCL"           = IP431.ppd

;
; Installer Sections
;
; These sections control file installation, and reference all files that
; need to be copied. The section name will be assumed to be the driver data
; file, unless there is an explicit DataFile section listed.
;
; Also note the ".NT" or ".WIN" notation. This is done to allow for a single INF to 
; work on Win9x and WinNT. When this format is used, the DataFile must be declared explicitly. 
; Win95 does not support this notation, so the old format is used.
; See the latest WinNT DDK for more info.   
;

[IP431.ppd.NT]
Delfiles=DELETE_FILES
CopyFiles=@IP431.ppd,PSCRIPT_NT
DataFile=IP431.ppd
DataSection=PSCRIPT_DATA_NT

[DELETE_FILES]
IP431Eng.Dll
IP431UI.Dll
IP431DNT.Dll
IP431RS.Dll
IP431RS2.Dll
IP431NT.Cnt
IP431NT.Hlp
IP431.ppd
2\IP431Eng.Dll
2\IP431UI.Dll
2\IP431DNT.Dll
2\IP431RS.Dll
2\IP431RS2.Dll
2\IP431NT.Cnt
2\IP431NT.Hlp
2\IP431.ppd
2\IP431.bpd

; Copy Sections
;
; Lists of files that are actually copied. These sections are referenced
; from the installer sections above. Only create a section if it contains
; two or more files (if we only copy a single file, identify it in the
; installer section, using the @filename notation) or if it's a color
; profile (since the DestinationDirs can only handle sections, and not
; individual files).
;

[PSCRIPT_NT]
IP431Eng.Dll,IP431Eng.Dl_
IP431UI.Dll,IP431UI.Dl_
IP431DNT.Dll,IP431DNT.Dl_
IP431RS.Dll,IP431RS.Dl_
IP431RS2.Dll,IP431RS2.Dl_
IP431NT.Cnt
IP431NT.Hlp


;
; Data Sections
;
; These sections contain data that is shared between devices.
;

[PSCRIPT_DATA_NT]
DriverFile=IP431Eng.Dll
ConfigFile=IP431UI.Dll
HelpFile=IP431NT.Hlp


;
; Call SetupSetDirectoryId with 66000 to set the target directory at runtime
; (depending on which environment drivers are getting installed)
;

[DestinationDirs]
DefaultDestDir=66000

;
; diskid = description,tagfile,unused,subdir
;

[SourceDisksNames.x86]
1 = %spd%
2 = %spd2%

;
; filename_on_source = diskid,subdir,size,checksum,spare,spare
; extra fields are nt-specific
;   bootmediaord,targetdirectory,upgradedisposition,textmodedisposition,targetname
;
[SourceDisksFiles]
IP431.ppd = 1
IP431Eng.Dl_ = 1
IP431UI.Dl_ = 1
IP431DNT.Dl_ = 1
IP431RS.Dl_ = 1
IP431RS2.Dl_ = 1
Dbwdll32.Dl_ = 1
IP431NT.Cnt = 1
IP431NT.Hlp = 1


;
; Localizable Strings
;
[Strings]
Company="Konica"
spd="Konica IP-431 PCL Disk 1 for NT 4.0"
spd2="Konica IP-431 PCL Disk 2 for NT 4.0"

I want to read the Manufacturer section and return the "Konica".

Link to comment
Share on other sites

Not through the Ini* functions... but you can easily grab the info if we can make some assumptions about the data..

for instance if the info you want is always on the line following [Manufacturer] then this would work:

$file = FileOpen(@ScriptDir & "\testing.ini", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$GrabNextLine = 0
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If StringMid($line, 1, 14) = "[Manufacturer]" Then 
        $GrabNextLine = 1
        ContinueLoop
    EndIf
    If $GrabNextLine = 1 Then
        MsgBox(0, "Info", $line)
        $GrabNextLine = 0
    EndIf
WEnd

FileClose($file)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Not through the Ini* functions... but you can easily grab the info if we can make some assumptions about the data..

for instance if the info you want is always on the line following [Manufacturer] then this would work:

$file = FileOpen(@ScriptDir & "\testing.ini", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$GrabNextLine = 0
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If StringMid($line, 1, 14) = "[Manufacturer]" Then 
        $GrabNextLine = 1
        ContinueLoop
    EndIf
    If $GrabNextLine = 1 Then
        MsgBox(0, "Info", $line)
        $GrabNextLine = 0
    EndIf
WEnd

FileClose($file)
Thnanks that seems to work I just need to do a little rewrite for when they do have a value.
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...