From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,98726e33eaf68ac4,start X-Google-Attributes: gid103376,public From: matthew_snyder@hotmail.com Subject: RE: ObjectAda: LPCSTR -> STRING ? Date: 1998/01/20 Message-ID: <885329887.836370436@dejanews.com>#1/1 X-Deja-AN: 317784937 X-Originating-IP-Addr: 208.139.144.190 (hawc-mci.indy.navy.mil) X-Authenticated-Sender: matthew_snyder@hotmail.com X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Organization: Deja News Posting Service X-Article-Creation-Date: Tue Jan 20 20:58:07 1998 GMT Newsgroups: comp.lang.ada Date: 1998-01-20T00:00:00+00:00 List-Id: OK. Here's what I ended up doing. Please let me know if there's an easier way. type CHARACTER_POINTER is access CHARACTER; function TO_CHARACTER_POINTER is new ADA.UNCHECKED_CONVERSION( WIN32.LPCSTR, CHARACTER_POINTER ); function TO_UNSIGNED_32 is new ADA.UNCHECKED_CONVERSION( WIN32.LPCSTR, UNSIGNED_32 ); function TO_LPCSTR is new ADA.UNCHECKED_CONVERSION( UNSIGNED_32, WIN32.LPCSTR ); procedure TO_ADA_STRING( STRING_PTR : in WIN32.LPCSTR; NEW_STRING : in out STRING; LAST : in out INTEGER ) is TEMP_STRING_PTR : WIN32.LPCSTR := STRING_PTR; ADA_STRING : STRING( 1 .. 80 ); TEMP_32 : UNSIGNED_32; CHAR_PTR : CHARACTER_POINTER; begin -- Get the length of the string LAST := INTEGER( WIN32.WINBASE.LSTRLEN( STRING_PTR ) ); -- Loop through and copy "C" string to Ada string for STRING_INDEX in 1 .. LAST loop -- Convert the string pointer to a character pointer CHAR_PTR := TO_CHARACTER_POINTER( TEMP_STRING_PTR ); -- Add the character to the ada string ADA_STRING( STRING_INDEX ) := CHAR_PTR.all; -- Convert the string pointer to an unsigned 32 TEMP_32 := TO_UNSIGNED_32( TEMP_STRING_PTR ); -- Increment the unsigned 32 TEMP_32 := TEMP_32 + 1; -- Convert the unsigned 32 back to a string pointer TEMP_STRING_PTR := TO_LPCSTR( TEMP_32 ); end loop; NEW_STRING( 1 .. NEW_STRING'LAST ) := ADA_STRING( 1 .. NEW_STRING'LAST ); end TO_ADA_STRING; -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet