Below are 5 lines of comma-delimited text which I wish to manipulate with the code below it. The lines of text constitute the file 'strfilename'
I have verified that the variable 'secondpt' has the value of 2 (I set a break point and observed it)
Here is the issue: The program loops through the lines of text and parses the first character (coord(0)) in the order it should but WILL NOT execute the next line of code when it compares 'secondpt' with 2. If I use the actual number 2, then it works. It has no problem with 'firstpt' which is 1 ( I didn't include the code for that). I looked for a 'trim' or 'strtrim' thinking that maybe a leading space was causing the problem but couldn't find one. My app will be using this method a lot so I need to solve the problem. Thanks for all the past support your have given.
Jim
1,1000,1000,none
2,1027.699,1030.228,none
3,5000,5000,iron rod
4,993.547,6987.254,none
B4X:
Sub Globals
'Declare the global variables here.
Public dblnorth1,dbleast1,dblndiff,dblediff,dblbearing,dblbearingdms
Public dblnorth2,dbleast2
Dim firstpt,secondpt
Dim coord(4) '[color=red]array for variable 'coord'[/color]
radian=cPI/180
radianreverse=180/cPI
End Sub
Sub startinverse8(strbearing)
FileClose(c)
FileOpen(c, main.strfilename,cRead)
pintcntr = StrIndexOf(strBearing, "*",0) [color=red]strbearing=1*2[/color]
firstpt = SubString(strBearing, 0, pintcntr)
secondpt = SubString(strBearing, pintcntr+1,StrLength(strbearing)-pintcntr)
lineoftext=""
Do Until lineoftext = EOF
lineoftext=FileRead(c) '[color=red] reads each line consecutively[/color]
coord()=StrSplit(lineoftext,",")
If coord(0)= secondpt Then '[color=red] first character in the line of text [/color]
dblnorth2=coord(1)
dbleast2=coord(2)
Exit '[color=red] exit the loop when coord(0)=2 (second pt)[/color]
End If
Loop
-
-
-
I have verified that the variable 'secondpt' has the value of 2 (I set a break point and observed it)
Here is the issue: The program loops through the lines of text and parses the first character (coord(0)) in the order it should but WILL NOT execute the next line of code when it compares 'secondpt' with 2. If I use the actual number 2, then it works. It has no problem with 'firstpt' which is 1 ( I didn't include the code for that). I looked for a 'trim' or 'strtrim' thinking that maybe a leading space was causing the problem but couldn't find one. My app will be using this method a lot so I need to solve the problem. Thanks for all the past support your have given.
Jim