Hello,
I fixed the previously mentioned problem, when some entries were skipped and the current project had to be smaller the one which should be imported. There seems to be a problem with variables and their scope, in the below example, which works now, I use "DebugPrint("counter..", i)" this works, but when useing i in the for-loop before this lead to problems for the entries 0, 1 and 2.
As I have had this problems before, I would like to know what to do about it. Am I encouraged to make more frequent use of the "local"-statement or should i get hold of the used helper-variables and change these throughout the project?
Code: Select all
Function p_ExecImport()
Global imported = 0
;Nation
If ImpNationCount > 1
For counter = 0 To (ImpNationCount-1) Step 1
DebugPrint("NC..",NationCount)
DebugPrint("counter..", i)
p_defTab(t_nation, NationCount,NationCount+1, 1)
newid = p_CreateID()
t_nation[NationCount][0]= newid
t_nation[NationCount][1]= t_IMPnation[counter][1]
t_impRef[imported][0] = t_IMPnation[counter][0]
t_impRef[imported][1] = newid
imported = Add(imported, 1)
NationCount = Add(NationCount,1)
Next
ElseIf(ImpNationCount = 1)
p_defTab(t_nation, NationCount,NationCount+1, 1)
newid = p_CreateID()
t_nation[NationCount][0]= newid
t_nation[NationCount][1]= t_IMPnation[0][1]
t_impRef[imported][0] = t_IMPnation[0][0]
t_impRef[imported][1] = newid
imported = Add(imported, 1)
NationCount = Add(NationCount,1)
EndIf()