[Gambas-user] Catch NULL character
CelticBhoy
weldon_gary at ...67...
Sat Mar 28 13:54:11 CET 2009
This is the code where the problem comes up :-
PUBLIC SUB Seperate(sComponent AS String, iRec AS Integer)
DIM sElement AS String[13]
DIM iStart AS Integer
DIM iFinish AS Integer
DIM iLen AS Integer
DIM iLoop AS Integer
DIM iSlen AS Integer
iLen = Len(sComponent)
IF iLen > 1 THEN
iStart = 1
FOR iLoop = 1 TO 11
iFinish = InStr(sComponent, ",", iStart)
iSlen = iFinish - iStart
sElement[iLoop] = Mid$(sComponent, iStart, iSlen)
IF sElement[iLoop] = NULL THEN sElement[iLoop] = "0"
iStart = iFinish + 1
NEXT
sElement[12] = Right$(sComponent, (iLen - iFinish))
IName[iRec] = sElement[1]
PSize[iRec] = Val(sElement[2])
SDiv[iRec] = Val(sElement[3])
SOnHand[iRec] = Val(sElement[4])
ICost1[iRec] = Val(sElement[5])
ICost2[iRec] = Val(sElement[6])
ICost3[iRec] = Val(sElement[7])
ICost4[iRec] = Val(sElement[8])
BSell[iRec] = Val(sElement[9])
OSSell[iRec] = Val(sElement[10])
OSMult[iRec] = Val(sElement[11])
MSize[iRec] = Val(sElement[12])
ENDIF
END
All arrays apart from IName[] & sElement[] are type float.
example of file input :-
Delour,1,20,0,0,7.95,,0,1.3,,0,0
Martell,1,20,0,15.59,13.17,13.94,0,1.9,16.99,0,0
Bacardi,1,42.8,0,23.99,23.15,24,0,1.55,0,0,0
Bacardi,1,20,0,10.61,11,10,,0,12.99,0,0
OVD,1,20,0,0,,23,0,1.5,13.75,0,0
Morgans,1,42.8,0,24.19,22.65,23,0,1.55,0,0,0
The text file was generated from a spreadsheet which has some empty cells,
as you can see each record has twelve fields. The problem arises when trying
to assign the empty fields to the float arrays.
Thanx in advance for any help.
PS I got round the problem by filling in the empty cells in the spreadsheet,
but I would still like to know where I went wrong.
PPS Where can I download Gambas 3 for Ubuntu ???
--
View this message in context: http://www.nabble.com/Catch-NULL-character-tp22751957p22756585.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list