Android Question Error loading B4xtable

Emerito

Active Member
Licensed User
Longtime User
Load a B4xTable from a text file whose lines have the following format, separated by commas
Example of a file line:
0.204.5.2, FEDERAL 204 Ruger NOSLER Ballistic Tip, 32.2,0.206,1228,1143,1063,987,916,847,782, -3.8,0.3,2.5,2.5,0, -5.4, -14.3,1563,1355,1172,1010, 870,744,634,0.11,10014

partial code:
Main.DirCartuchos = File.DirRootExternal & "/ DeCazaGPS / Balistica"
Main.FicheroCartuchos="Cartuchos1.txt"
Dim data As List = su.LoadCSV2 (Main.DirCartuchos, Main.FicheroCartuchos, ",", headers)
Up to here everything is correct and working.

If I add to the file "cartuchos1.txt" a line from the program with:
Dim tw As TextWriter

tw.Initialize( File.OpenOutput(Main.DirCartuchos,Main.FicheroCartuchos,True))

tw.Write (EdtCalPul.text)
tw.Write (",")
tw.Write (EdtCalibreMM.text)
tw.Write (",")
tw.Write (EdtDeno.Text)
tw.Write (",")
tw.Write (NumberFormat (EdtGrains.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtGramos.Text, 1,1))
tw.Write (",")
tw.Write (EdtCB.Text)
tw.Write (",")
tw.Write (NumberFormat (EdtV0.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV50.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV100.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV150.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV200.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV250.Text, 1.0))
tw.Write (",")
tw.Write (NumberFormat (EdtV300.Text, 1.0))
tw.Write (",")
tw.Write (EdtElev0.Text)
tw.Write (",")
tw.Write (EdtElev50.Text)
tw.Write (",")
tw.Write (EdtElev100.Text)
tw.Write (",")
tw.Write (EdtElev150.Text)
tw.Write (",")
tw.Write (EdtElev200.Text)
tw.Write (",")
tw.Write (EdtElev250.Text)
tw.Write (",")
tw.Write (EdtElev300.Text)
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV0.Text * EdtV0.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV50.Text * EdtV50.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV100.Text * EdtV100.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV150.Text * EdtV150.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV200.Text * EdtV200.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV250.Text * EdtV250.Text * 0.001))
tw.Write (",")
tw.Write (Round (0.5 * EdtGramos.Text * EdtV300.Text * EdtV300.Text * 0.001))
tw.Write (",")
tw.Write ("0.5")
tw.Write (",")
tw.Write (EditText1.Text)
tw.Close

this is the line recorded in the txt file
0.51,13,SAKO 500 Jeffery TWINHEAD II,535,34,0.285,710,663,616,573,530,492,454,-4.5,2.8,4.0,0.0,-12.5,-33.0,-64.7,8570,7473,6451,5582,4775,4115,3504,0.5,11919


When I come back to:
Dim data As List = su.LoadCSV2 (Main.DirCarts, Main.FileCards, ",", headers)

I miss the following error:
java.lang.StringIndexOutOfBoundsException: length = 304602; regionStart = 304596; regionLength = -304597

Could you help me solve it?

Greetings.
 

Emerito

Active Member
Licensed User
Longtime User
Sin la última línea, el archivo es válido.
No he adjuntado el código porque es parte de un proyecto mucho más amplio, pero si lo desea, le enviaré el proyecto completo.
lamento mis errores
 

Attachments

  • cartuchos1.zip
    92 KB · Views: 216
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
[QUOTE = "Emerito, post: 669953, miembro: 84497"] Sin la última línea, el archivo es válido.
No se adjuntó el código porque es parte de un proyecto mucho más amplio, pero si lo desea, le enviaré el proyecto completo.
lamento mis errores [/ QUOTE]
 

Attachments

  • Screenshot_20190626-211150.png
    Screenshot_20190626-211150.png
    163.4 KB · Views: 198
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
Were you able to solve the problem?
No, I have a file in Assets that when I start the application I copy it to the SD (DirRootExternal) in order to write it. When I add a line with tw.write I can not load the B4xTable table. That's when I get the error: java.lang.StringIndexOutOfBoundsException: length = 304602; regionStart = 304596; regionLength = -304597 and I do not understand what the cause is.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Normally @Erel highly advises against the use of TexWriter and TextReader, particularly in the way it was used in this thread.
 
Upvote 0
Top