[Gambas-user] Adding integers to an array fails with "Null Object" error

Benoit Minisini gambas at ...1...
Sat Jun 2 14:03:31 CEST 2007


On samedi 02 juin 2007, easuter wrote:
> Hi there,
>
> I'm trying to get a piece of code to work that should cut the interface
> number of any alias in /etc/modprobe.conf called wlanX, where X is the
> interface number.
>
> My app will be adding wlanX aliases, and needs to know any pre-existing
> interface number in that file.
>
> Anyway I decided to use an array to contain the interface numbers.
> The problem is that I get a "Null Object" error from the Gambas debugger
> when running the app inside the IDE.
>
> This is the code:
>
> -----------------------------------------------------
>
> OPEN AliasConfig FOR READ AS #hAliasConfig
>   WHILE NOT Eof(hAliasConfig)
>
>     LINE INPUT #hAliasConfig, sLine
>
>     'Check for ndiswrapper specific aliases first
>     IF Instr(sLine, " ndiswrapper") > 0 THEN
>       INC iAliasCount
>
>       'Turn all the interface names into one string
>       sAliases = sAliases & Mid$(Left$(sLine, Instr(sLine, "
> ndiswrapper")), Instr(sLine, " "))
>     ENDIF
>
>     'This section will check for pre-existing wlanX alises, so as to
>     'not overwrite them (ndiswrapper uses wlan0 by default).
>     IF Instr(sLine, "wlan") > 0 THEN
>       sWlanX = Mid$(Left$(sLine, RInstr(sLine, " ")), Instr(sLine,
> "wlan")+4)
>       ariWlanXList.Add(Val(sWlanX))
>     ENDIF
>
>   WEND
>   CLOSE #hAliasConfig
>
>   ariWlanXList.Sort(GB.Ascent)
> ----------------------------------------------------------
>
> So for example, if wlan0 is found then sWlanX will be a string "0".
> When I run the program in the IDE, the debugger spits out the Null Object
> error and then jumps to the "ariWlanXList.Add(Val(sWlanX))" line.
> ariWlanXList is an interger array.
> My intention is then to sort the array to find the highest interface
> number.
>
> Any idea why this happens? What should I fix? The "Null Object" error is
> rather vague....

Which version of Gambas do you use?

-- 
Benoit Minisini




More information about the User mailing list