I have this function that work fine.

Code: Select all

```
Function OpenAIWFile(file$)
/* Read waypoints from aiw file */
split$ = {}
score$ = {}
value$ = {}
wp_x = {}
wp_y = {}
wp_branchID = {}
wp_score = {}
wp_wpseA = {}
wp_wpseB = {}
wp_bitfields = {}
j=0
OpenFile(1, file$)
While Not Eof(1)
row$ = ReadLine(1)
split$ = SplitStr(row$,"=")
Switch split$[0]
Case "wp_pos":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
value$ = SplitStr(string$,",")
wp_x[j] = Val(value$[0])
wp_y[j] = -1 * Val(value$[2])
Case "wp_branchID":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
wp_branchID[j] = Val(string$)
Case "wp_bitfields":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
wp_bitfields[j] = Val(string$)
Case "wp_wpse":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
value$ = SplitStr(string$,",")
wp_wpseA[j] = Val(value$[0])
wp_wpseB[j] = Val(value$[1])
Case "wp_score":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
score$ = SplitStr(string$,",")
wp_score[j] = Val(score$[0])
Case "WP_PTRS":
j = j + 1
EndSwitch
Wend
CloseFile(1)
EndFunction
```

But when I change the code to do this, I get the error: Table field 0 was not initialized!

This is the new function:

Code: Select all

```
Function OpenAIWFile(file$)
/* Read waypoints from aiw file */
split$ = {}
score$ = {}
value$ = {}
wp_x = {}
wp_y = {}
wp_branchID = {}
wp_score = {}
wp_wpse = {}
wp_bitfields = {}
j=0
OpenFile(1, file$)
While Not Eof(1)
row$ = ReadLine(1)
split$ = SplitStr(row$,"=")
Switch split$[0]
Case "wp_pos":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
value$ = SplitStr(string$,",")
wp_x[j] = Val(value$[0])
wp_y[j] = -1 * Val(value$[2])
Case "wp_branchID":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
wp_branchID[j] = Val(string$)
Case "wp_bitfields":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
wp_bitfields[j] = Val(string$)
Case "wp_wpse":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
value$ = SplitStr(string$,",")
wp_wpse[j][0] = Val(value$[0])
wp_wpse[j][1] = Val(value$[1])
Case "wp_score":
string$ = TrimStr(TrimStr(split$[1],"(", False),")",True)
score$ = SplitStr(string$,",")
wp_score[j] = Val(score$[0])
Case "WP_PTRS":
j = j + 1
EndSwitch
Wend
CloseFile(1)
EndFunction
```

Thanks in advance