PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Android arrayDeleteLine replacement
Android arrayDeleteLine replacement
Iniciado por Stewart MICHAEL, 15,sep. 2016 10:44 - 1 respuesta
Publicado el 15,septiembre 2016 - 10:44
Apparently Android does not have an equivalent for this function and so I wrote my own. Sadly this is running into an unexpected issue. I am essentially converting the array to a string removing the line from the string and then putting it back.

The strange thing is that this works once but any attempts to repeat the process result in the stringToArray line failing and I end up with a one dimensional array not a two.

Procedure garrFileRemoveLine(i)
sArr is string = ArrayToCSV(garrFile,";")

SWITCH i
CASE 1
sArr=Right(sArr,Length(sArr)-PositionOccurrence(sArr,CR,1)+1)
CASE ArrayCount(garrFile)
sArr = Left(sArr,PositionOccurrence(sArr,CR,i-1)-1)
OTHER CASE
nCut1 is int =PositionOccurrence(sArr,CR,i-1)+1
nCut2 is int = PositionOccurrence(sArr,CR,i)+1
sLeft is string = Left(sArr,nCut1)
sRight is string = Right(sArr,Length(sArr)-nCut2)
sArr=sLeft+sRight
END
DeleteAll(garrFile)
StringToArray(sArr,garrFile,CR,";")
gnFileDown = ArrayCount(garrFile)
gnFileAcross = Dimension(garrFile)/gnFileDown


Any suggestions greatly welcome

Thanks

Mike
Publicado el 15,septiembre 2016 - 16:14
those eagle eyed among you will have spotted that the + on the top line of code should have been a minus...

This line at present creates a blank line at the top of the file.

The next time the code is used the code assumes that the array only has 1 column as there is nothing in it to tell it otherwise