Pojem dynamicka struktura chapu jako v pascalu record. Coz moc dynamicke neni, pac se to musi definovat predem, ale budiz.
google = pascal record simple example
Hned prvni stranka je
http://pascal-programming.info/lesson11.php
Vemu si ten uplne posledni nejdelsi priklad.
- Str25 ja struktura string delky 25
- TBookRec je struktura asociativni pole s nekolika prvky zalozenymi na strukture Str25 (v jinem jazyce nazvane object nebo class)
- bookRecArray je struktura pole zalozene na strukture TBookRec;
- kdyz pak do toho pridavam, tak
bookRecArray[i].Title = ...
Cili, to, co ty muzes ted hodit pres ukazatel je podle meho spis cele to pole bookRecArray. Pripadne by mozna slo vsechno, ale bylo by to asi narocne na zatez pri vetsim poctu prvku, treba 50.000.
google = pascal new record example (nezda se mi tvuj zapis pouziti new)
http://www.tutorialspoint.com/…_records.htm
na konci stranky je takovy dlouhy example
program exRecords;
type
BooksPtr = ^ Books;
Books = record
title: packed array [1..50] of char;
author: packed array [1..50] of char;
subject: packed array [1..100] of char;
book_id: longint;
end;
var
(* Declare Book1 and Book2 of pointer type that refers to Book type *)
Book1, Book2: BooksPtr;
begin
new(Book1);
new(book2);
(* book 1 specification *)
Book1^.title := 'C Programming';
Book1^.author := 'Nuha Ali ';
Book1^.subject := 'C Programming Tutorial';
Book1^.book_id := 6495407;
(* book 2 specification *)
Book2^.title := 'Telecom Billing';
Book2^.author := 'Zara Ali';
Book2^.subject := 'Telecom Billing Tutorial';
Book2^.book_id := 6495700;
(* print Book1 info *)
writeln ('Book 1 title : ', Book1^.title);
writeln('Book 1 author : ', Book1^.author);
writeln( 'Book 1 subject : ', Book1^.subject);
writeln( 'Book 1 book_id : ', Book1^.book_id);
(* print Book2 info *)
writeln ('Book 2 title : ', Book2^.title);
writeln('Book 2 author : ', Book2^.author);
writeln( 'Book 2 subject : ', Book2^.subject);
writeln( 'Book 2 book_id : ', Book2^.book_id);
dispose(Book1);
dispose(Book2);
end.
Seznam := Novy;
To nepridava na zacatek seznamu, ale prepisuje celou promeneou Seznam obsahem promenne Novy. Abys to pridaval do pole, musel by byt seznam pole a muselo by to byt zapsane tak, jak jsem psal na zacatku bookRecArray[i] = novy