Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-10

how to work with dynamic arrays

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mgr. Janusz Chmiel

Because dynamic arrays are very important, how to work with them. If I will declare
var
a: array of string;
How could I add several values to this dynamic array? because a (1) :='ahoj';
do not work.
Even if I would add other type of parentheses instead of (); Because I need to use some index to fill out The table with given data.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201017/eceda3b0/attachment.htm>

Reply by email

Michael Van Canneyt
to Mgr. Janusz Chmiel
Mgr. Janusz Chmiel wrote 6 lines
Because dynamic arrays are very important, how to work with them. If I will declare var a: array of string; How could I add several values to this dynamic array? because a (1) :='ahoj';

You must set the size first.

// Allocate 10 elements
SetLength(a,10):
// Array is zero based.
a[0]:='ahoj';
a[1]:='hello';
...
a[9]:='The last of the Mohicans';

Michael.

Reply by email

Mgr. Janusz Chmiel
to Michael Van Canneyt: You must set the size first. // Allocate 10 elements SetLength(a,10): // Array is zero…

I AM attaching small .pas code with The eventtable. My goal is to have The possibility to use dynamic array to fill The table with various values. BUt I Am having troubles with The case. How to add The variable counter and other command at The one line so case selector will work? Thank you for yours help.
By The way. Does my attempt with dynamic array have The sense? Will I have The possibility to store various values by using this approach? Or I can not do this by using that way?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eventtable.pas
Type: application/octet-stream
Size: 435 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201017/ce71119d/attachment.obj>

Reply by email

Mgr. Janusz Chmiel
to Mgr. Janusz Chmiel

Here is my attempt. But because I have removed case selector, Screen reader have no chance to get 100 % table accessibility status like it is when Case selector have been used.
But it is very probably impossible to combine Case selector with For cycle. I AM having A good ideas, but I Am always finding some internal Pascal language limitations. Such as.
It is impossible to write more than one command after case in a one line, : or ; is not A solution.
But I AM really triing to adapt The code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demohtmlwidgets.pp
Type: application/octet-stream
Size: 10824 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201017/cd219f95/attachment.obj>

Reply by email