About Francis Kong Expertise Pascal programming. I would be best at solving logic and syntax errors with some given code, or some programming theory and specific task. I have done mostly my pascal within a machine(meaning, not networking and serial cable yet)and I am not able to solve things in ObjectWindows... I should be able to answer most of the thing done in console(dos and x systems like linux) platform and in Mac(but for Mac I can only handle nonplatform-specific questions). Feel free to ask me, because if I am not able to answer it I might be able to tell where to get the specific material that you need
Experience teached a classmate with an exam mark of 56% and the second shot with a higher difficulty the tutee gets more than 80%
Expert: Francis Kong Date: 1/22/2004 Subject: arrays in Turbo Pascal
Question How can I make an array with a variable index type in Turbo Pascal?
for example sth like this:
Var x:byte;
ar:array[1..x] of Char;
Answer you don't. for variable length array (not that you'll really need them anyways, just make a static length long enough for the maximum case) , try use the following:
in the declaration:
var p,q: ^char;
k: integer;
in the program:
before you try to use the array, use getmem to initialize it like (the following has no error checks, so if you need some of those, look into the help file):
{get a value of k from input or assignment}
getmem(p,k*sizeof(char));
to access the array, try this:
q := p; {the first element}
q^ := 'A'{or whatever you like}
inc(q); {This goes to the next one, look into "inc" and "dec" in help for more details}