[fpc-pascal] a few trivial questions
spir ☣
denis.spir at gmail.com
Wed May 12 16:33:13 CEST 2010
Hello,
* TFPList
Is there another way to traverse a list than
for i :=0 to (list.count - 1) do ...
What about list.high?
Also, is it possible to set a list's base index to 1 (so that last_index=count)?
There is a super handy forEachCall method (calling a proc for each item), but I cannot find a matching map method (calling a func and storing results).
* string <-> number
I could not find _functions_ to operate such conversions, only _procedures_ str and val. So that I always end up with superfluous statements and temps variables:
str(n,text);
writeln(text);
vs
writeln(NumbetToString(n));
Ok, I can write these funcs (I did ;-). But how comes there are no builtin functions for that?
* string section
Is there another way to slice a string than using copy. In particuliar, the count argument is not always practical to indicate the end_of_section position. (count = last-first+1)
* array value notation
I can set a static array's value on declaration line, but could not find a way to do it later (even less to change it). And I cannot find a way to set the value of a dynamic array --when it's not fed from a loop. End up with series of arr[i]:=v statements (code from the http://en.wikipedia.org/wiki/Middle_ages ;-). Same for lists, indeed.
var
arr : array [1..2] of Integer;
...
i:=1 ; j:=2;
arr := (i,j);
==> Syntax error, ")" expected, but "," found
Finally: is there a wiki version of the official docs, to collectively enhance them (with notes, examples, explanations...). (I'm dreaming, but after all fpc is free software, and it's the #1 reason why I chose it.) (*)
Denis
(*) This gives me an idea: a converse doc system that takes properly formatted doc and inserts proper parts of it as comment into the code at their proper place -- not the contrary ;-)
[class TFoo]
...
[method Do]
... )
... > inserted just before/after TFoo.Do's header in code
... )
[/method]
...
[/class]
________________________________
vit esse estrany ☣
spir.wikidot.com
More information about the fpc-pascal
mailing list