PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Lists, Structures etc (0.7a)

Hello All,

I have attached a ZIP archive of a small sample program. If you are going to attempt to run the sample code please remember to transfer the file "mylist" (an ascii file) into the application directory on your PDA (\my documents\ppl on a standard setup).

As coded the sample program reads information from the ascii text file (mylist) and loads it into a structured list and then performs a "ShowList" to display the contents of the loaded list. This "test" is initiated by selecting TESTS/TEST #1 from the main menu).

Question 1:
-----------

You will note from the ascii text file that the info is read in order 160,161,162,180,181,182,200,201,202.

The information is displayed from the list (using foreach (MyList$)) and shows the last element read (202) as the first element in the list. The others are in correct order.

Why?

Question 2:
-----------

If you examine my code the "ShowMyList" is called on the completeion of the "LoadMyList" procedure (in file "MyList.PPL").

If you would comment out this line - "ShowMyList" and then go to the file "Testing.PPL" where you will find a routine "DoTestProc1". Uncomment the line "ShowMyList" in that procedure and re-run the program.

Note that the only difference to our previous program is that the list is displayed now immediately after exiting the "LoadMyList" procedure.

In this example the list genereated is seriously corrupted.

Why?

In both these cases I feel there must be something basic I am doing wrong. I have spent quite some time looking at alternatives approaches to attempt to unveil my error without success. Any comments or hints from other beta testers would ne much appreciated.
Attachments:
sample.zip (7 KB)
PointOfLight · 03 Aug 2004, 19:24 UTC
In answer to question #1: I believe there is a bug with linked-lists and structures, specifically in how the linked-list gets initialized. I have attached a modified version of your code that now works. The changes I made were in the LoadMyList function. It seems that if you modify a linked list item that is a structure immediately after you set it up, it throws off the pointer for the linked list. Anyway, my modifications should make sense, and hopefully kornalius can shed some more light on the subject.
Attachments:
sample.zip (7 KB)
In regards to question #1:

I was able to reproduce the problem here. This will be fixed in 0.7b.

Question #2:

Ironically, this problem has been fixed with 0.7b. I worked on fixing the garbage collection system in the last few days in order to fix this kind of problem.

I just tested both situations with this program and the result was what it was suppose to be.

Code:
// list with struct elements

proc test;
global (l$);
list (l$);
while (i$ <= 3)
add (l$);
struct (l$, "a", "b");
l.a$ = i$;
l.b$ = i$ * 2;
i$ ++;
end;

end;

proc main
test;
foreach (l$)
ShowMessage (l.a$ + "," + l.b$);
end;
end;
Firstly many thanks to Eric for taking the time and effort to review my code. I appreciate that reviewing someone elses code is no trivial exercise. I will apply your patch until 0.7b

To Kornalius again thanks for the effort. Its a bit worrying however that you are finding the errors one step ahead of our reports ... do you ever sleep?

BTW: I will be out of town for about 12 days from Friday 6th August so please don't interpret my absence from the forum as dis-interest. I'll be back into it as soon as I return.


cheers
PointOfLight · 04 Aug 2004, 03:28 UTC
What? You're leaving us? First kornalius, and now this :) Seriously, though, I hope you're going out of town is a good thing for you, and we'll see you when you get back. And kornalius, aren't you supposed to be on vacation again? Go vacate for a while!
Hi guys,

Yep, I am on vacation again. I will be out of town for a couple days very soon. I want to release 0.7b before leaving. :)

Mervejoyce: I will test your code with 0.7b tonight to make sure it is working properly.

I will be back with 0.8 in a couple weeks don't worry. :twisted:
PointOfLight · 04 Aug 2004, 20:36 UTC
Oh, I'm not worried. It still boggles my mind how you get so much accomplished vs. certain other PPC development packages I've used (I won't name any names no more, because I don't want 'em to get mad at me :D )