jcmcbeth Beginner
Joined: 18 Sep 2008 Posts: 13 Location: Charlotte, NC
|
Posted: Sat May 07, 2011 4:22 pm
Weird Find behavior |
This is my trigger code:
Code: |
#LOCAL planet
$rec = %find(%1, Planets, Name);
#IF ($rec) {
$planet = %dbget($rec);
}
$planet.Name = %1;
$planet.System = %2;
$planet.Clan = %3;
$planet.Support = %4;
#IF ($rec) {
#DBPUT $rec $planet
#SAY Rec: $rec
#SAY Planet: $planet
} {
#NEW Planets $planet
} |
Capture text, first run:
Code: |
Planet Starsystem Governed By Popular Support
Terra Prime Terra Prime Earth Alliance 99.0
Taurinia Tauri Earth Alliance 50.0
Solaris Solaris Solarian Federation 100.0
Solaria Solaris Solarian Federation 100.0
Centauri Centauri Centauri Consortium 30.0
Use SHOWPLANET for more information. |
The data is inserted into an empty database as expected.
Output of second run:
Code: |
Terra Prime Terra Prime Earth Alliance 99.0
Rec: 65pl
Planet: Num=65pl|Name=Terra Prime|X=0|Y=0|Z=0|System=Terra Prime|Support=99|Clan=Earth Alliance
Taurinia Tauri Earth Alliance 50.0
Rec: 66pl
Planet: Num=66pl|Name=Taurinia|X=0|Y=0|Z=0|System=Tauri|Support=50|Clan=Earth Alliance
Solaris Solaris Solarian Federation 100.0
Rec: 67pl
Planet: Num=67pl|Name=Solaris|X=0|Y=0|Z=0|System=Solaris|Support=100|Clan=Solarian Federation
Solaria Solaris Solarian Federation 100.0
Rec: 68pl
Planet: Num=68pl|Name=Solaria|X=0|Y=0|Z=0|System=Solaris|Support=100|Clan=Solarian Federation
Centauri Centauri Centauri Consortium 30.0
Rec: 69pl|69pl|69pl|69pl|69pl
Planet: Num=69pl|Name=Centauri|X=0|Y=0|Z=0|System=Centauri|Support=30|Clan=Centauri Consortium
Use SHOWPLANET for more information. |
What this then does is replace those 5 records with 5 of the same record, same ID and all, with the exception that the "Clan" field is unchanged.
It seems the main issue is why it works fine until the last triggering element where %find returns the same record id 5 times. It seems at this point the previous 4 records are somehow replaced with the last record.
This is either some kind of bug or what am I doing wrong? |
|