Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: Using a var...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 709 of 811
Post > Topic >>

Re: Using a variable within a record

by "JP2R" <jp-dezaire@[EMAIL PROTECTED] > Jan 19, 2007 at 04:35 AM

Dennis-Bendert Schramm a =E9crit :
> Hi,
>
> how can I get the following piece of code to work:
>
>
> type MenuRec=3DRECORD
>          word_menuItem:word;
>          word_itemNumber:word;
>          p_itemArray:array[1..word_itemNumber]of pchar; {<- error occurs
> here! }
> END;
>
>
The next question would be what will you do with MenuRec ? and how
"safe" you want it (safe is more or less class with methods)
now if p_itemArray is a pointer as his name suggests you can call
GetMem to have it as you need;
but declarations must be changed:

TYPE TitemsArray =3D array [0 ..(* let's say ...*) high(word) ] of pchar;
          P2itemArray =3D ^TitemArray;

          MenuRec=3DRECORD
             word_menuItem:word;
             word_itemNumber:word;
             p_itemArray:P2itemsArray (* call getmem/freemem *)
          END;

Now if you need the record in one piece in memory (* for example to
interface with C struct ...*)

 TYPE TP2newrec : ^ NewMenuRec;

      NewMenuRec =3D RECORD
             word_menuItem:word;
             word_itemNumber:word;
             itemArray: TitemsArray
            END;
VAR mymenu : TP2newrec; (* and get the size you need
2*sizeof(word)+(sizeof(pchar)*nNumberWord) *)
       =20
     :
 




 6 Posts in Topic:
Using a variable within a record
Dennis-Bendert Schramm &l  2007-01-18 01:48:14 
Re: Using a variable within a record
Alan <alan@[EMAIL PROT  2007-01-18 02:00:09 
Re: Using a variable within a record
Wolf Behrenhoff <NoSpa  2007-01-18 02:21:49 
Re: Using a variable within a record
Dennis-Bendert Schramm &l  2007-01-18 06:59:10 
Re: Using a variable within a record
Waldek Hebisch <hebisc  2007-01-19 10:39:54 
Re: Using a variable within a record
"JP2R" <jp-d  2007-01-19 04:35:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:42:56 CDT 2008.