[Gambas-user] Adding integers to an array fails with "Null Object" error
easuter
easuter at ...626...
Sat Jun 2 10:49:33 CEST 2007
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....
--
View this message in context: http://www.nabble.com/Adding-integers-to-an-array-fails-with-%22Null-Object%22-error-tf3856140.html#a10925241
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list