On 2 June 2010 11:34, spir <denis.s...@gmail.com> wrote: > Hello, > > > Is there a (builtin, simple) way to output the content of an array or of a > record. Something like arrayToStr / recordToStr, that would return a normal > form similar to the literal notation used for intialisation? If no, is there > a way to write custom funcs for this purpose (meaning access at runtime to > types of items/fields). I constantly need such a feature. > writeln(recordTostr(aPosition)) // --> (x:1 ; y:2 ; z:3) > writeln(arrayTostr(someInts)) // --> (9, 8, 7) > (Additionally, once we have this, a "view" func could call the appropriate > *ToStr according to actual type, and a "show" procedure could use writeln on > the result of view... then I'm happy :-) >
ooh. php has 'print_r' for printing arrays/objects - an equivalent ArrayToStr would be handy to have in Pascal. while pascal is my favourite language, I'm finding it poorly supported compared with php :( > Side-question, upon the opposite point, just to be really sure: array & > record literal notations can only be used in declaration (var/const), > meaning for initialisation. But cannot be used to assign a var in a > statement block. Correct? If yes, what is the issue (for the > parser/compiler/runtime)? > > > Denis > - V
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal