Page 1 of 1 1
Topic Options
#213785 - 2019-11-28 06:57 PM error in function ReadProfileString
Valentim Offline
Fresh Scripter

Registered: 2010-01-04
Posts: 46
Loc: Brazil, PE, Recife
I am trying to run the script below, but an error is displayed on line 4, would anyone have any suggestions?

 Code:
Break ON
$cor = @COLOR

$GrpArray = split(ReadProfileString($pFile, "", ""), chr(10))
For Each $Grupo in $GrpArray
    If $pOpc = "R"
        If ($Grupo = "Service")
            $GrpChave = split(ReadProfileString($pFile, $Grupo, ""), chr(10))
            $Server = ReadProfileString($pFile, $Grupo, "Name")
            ? COLOR +G/n $Grupo COLOR +Y/n " ->" COLOR +R/n " Service" COLOR +Y/n " = " COLOR +W/n $Server COLOR $cor
        EndIf
        If ($Grupo = "TCP")
            $GrpChave = split(ReadProfileString($pFile, $Grupo, ""), chr(10))
            $Port = ReadProfileString($pFile, $Grupo, "Port")
            ? COLOR +G/n $Grupo COLOR +Y/n " ->" COLOR +R/n " Port  " COLOR +Y/n " = " COLOR +W/n $Port   COLOR $cor
        EndIf
    EndIf
Next


 Code:
Port Tools
ERROR : invalid method/function call: too many parameters!
Script: M:\ports.kix
Line  : 4
_________________________

Top
#213786 - 2019-11-28 07:35 PM Re: error in function ReadProfileString [Re: Valentim]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
You haven't declared $pFile in your sample, but apart from that, if I don't do this here it doesn't die with too many parameters error..

If I create an ini file with some sections and point $pFile to it your line 4 perfectly creates an array with the section names. The rest of your functions look perfectly allright, except maybe that $pOpc wasn't set anywhere ;\)

I guess this is only part of a bigger script, right?
_________________________



Top
#213787 - 2019-11-28 07:42 PM Re: error in function ReadProfileString [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh by the way, the following will get rid of the last empty array element when reading in sections (or keys for that matter)

 Code:
$GrpArray = split(left(ReadProfileString($pFile, "", ""),-1), chr(10))
_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org