[21 Sep 2009] help with tables

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

[21 Sep 2009] help with tables

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 21 Sep 2009 14:30:21 +0200

Hello, I am currently on the task to implement a way to import a saved table into an existing one. This looks quite promising, but the mechanism fails if there is only one entry in an table which is suposed to be imported.

Further observations: It is only possible to import projects which are smaller than the current one. NationCount grows to the number of ImpNationCount and not further. It skips the first entry if there are more than one entry.

The part where the error jumps in is: The script jumps into an error when accessing "t_IMPnation[1]" when i = 0 and ImpNationCount = 1

Code: Select all

Function p_ExecImport()
    Global imported = 0
    ;Nation
    If ImpNationCount > 0
       DebugPrint("ImpNC:..",ImpNationCount)
       DebugPrint("NC:..", NationCount)
       For i = 0 To (ImpNationCount-1)
           DebugPrint("NC..",NationCount)
           DebugPrint("i..", i)
           p_defTab(t_nation, NationCount,NationCount+1, 1)
           newid = p_CreateID()
           t_nation[NationCount][0]= newid
           t_nation[NationCount][1]= t_IMPnation[i][1]

           t_impRef[imported][0] = t_IMPnation[i][0]
           t_impRef[imported][1] = newid

           imported    = Add(imported,   1)
           NationCount = Add(NationCount,1)
       Next
    EndIf()

Locked