Board index » delphi » 2d arrays

2d arrays

Hi. I am asking some really simple questions here..Only because I
haven't got the cash to by a Pascal book for a week or too

I would really appreciate any help at all .. Thanks

Here are my questions

1) How do you define a 2d string array and how would you call it in a
loop

2) How can I convert the value of a 2d string array to a real no?

3 and does any one have a function that will  convert alpanumbers to
realnumbers ??? ...

I need to be able to add text or a real no to a var and then convert
it or not to a real var then be able to do arithmetic with the
converted variables :) ....

Any help at all would be appreciated ...

Thanks again

Brett

 

Re:2d arrays


Quote
_meow <b...@halligan74.junglelink.co.uk> wrote:
> 1) How do you define a 2d string array and how would you call it in a
> loop

type my_array = array[1..10, 4..17] of string[20];
var mystrings: my_array;
    i, j: integer;
begin
  for i := 1 to 100 do
    for j := 4 to 17 do
      mystrings[i, j] := 'help me!';
end;

Quote
> 2) How can I convert the value of a 2d string array to a real no?

An entire array?? Surely you mean a single element, in which case using
Val() with mystrings[i, j] (or whatever) should work.

Quote
> 3 and does any one have a function that will  convert alpanumbers to
> realnumbers ??? ...

Val() again - I'm assuming that you have this, since you're posting to cplb.
If not, it's actually not too hard to write your own parser.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will
   sa...@maths.uwa.edu.au     |    come to ruin." -- Proverbs 13:3
______________________________|_______________________________________

Re:2d arrays


Quote
> > 1) How do you define a 2d string array and how would you call it in a
> > loop

> type my_array = array[1..10, 4..17] of string[20];
> var mystrings: my_array;
>     i, j: integer;
> begin
>   for i := 1 to 100 do

...               ^^^ You meant 10, right?
Quote
>     for j := 4 to 17 do
>       mystrings[i, j] := 'help me!';
> end;

> > 2) How can I convert the value of a 2d string array to a real no?

> An entire array?? Surely you mean a single element, in which case using
> Val() with mystrings[i, j] (or whatever) should work.

> > 3 and does any one have a function that will  convert alpanumbers to
> > realnumbers ??? ...

> Val() again - I'm assuming that you have this, since you're posting to cplb.
> If not, it's actually not too hard to write your own parser.

Re:2d arrays


var myarray : array[1..10] of string[10];
begin
 writeln(myarray[1]);
end.

look in the pascal help files to see how to convert reals to strings and
vice-versa. Val i think.

Ryan

Re:2d arrays


I think you should try:

-------------------------------------------

const n=100
type 2dstring=array[0..n] of string[n]
var square: 2dstring

--------------------------------------------

If this is not what you mean : email me !!!

Natha...@12move.nl

Other Threads