The package Interfaces.C has several subroutines that deal with null- 
terminated strings. From http://www.adahome.com/rm95/rm9x-B-03.html:


function Is_Nul_Terminated (Item : in char_array) return Boolean;
The result of Is_Nul_Terminated is True if Item contains nul, and is  
False otherwise.


There are a number of functions and procedures to convert stuff and  
they all look something like this. (Ada allows overloads so they go  
by the same name).

function To_C
        (Item : in String;
         Append_Nul : in Boolean := True)
         return char_array;

function To_Ada
        (Item : in char_array;
         Trim_Nul : in Boolean := True)
         return String;

Note also that Ada arguments are optional after the first one as long  
as they have a default value as determined by the := within the  
formal argument list, so To_C(In_String) is the same as To_C 
(In_String, True). Ada itself has extensive string processing built  
in and will initially drive one crazy with its three different string  
types. Werner's solution of appending the null character with & Nul  
does the same thing.

I'll look into this further as soon as I finish some minutia related  
to my weird Ada installation and getting the ctest stuff to work.

Jerry



On Mar 13, 2007, at 3:34 AM, Werner Smekal wrote:

> Hi Alan,
>> However, that was because I replaced
>> -    plbox("bc", 0.0, 0, "bc", 0.0, 0);
>> +    Box_Around_Viewport(TUB("bc"), 0.0, 0, TUB("bc"), 0.0, 0);
>>
>> If I use plbox rather than Box_Around_Viewport, then the result has
>> extraneous tick marks. I don't understand the cause of this  
>> problem.  The
>> same example has a call to plptex with another character array,  
>> and that
>> works without problems.  I have also carefully compared how plptex  
>> and plbox
>> are set up in plplotthin.ads, and I cannot spot anything. I also  
>> tried the
>> TUB("bc") in the argument list for plbox, but the compiler  
>> complained about
>> something being inconsistent before erroring out so I dropped it.
> I found the solution to this problem. Have a look into example x12.  
> The
> thin bindings of plplot need as strings char_array , but in Ada a '\0'
> is not automatically added. You need to do this on you own. You  
> need the
> "Interfaces.C" library/module/whatever and than add "& Nul" to the
> strings so that they have the correct ending. Maybe Jerry can tell you
> how exactly this is supposed to work, or give a better/nicer  
> solution to
> this problem.
>
> Regards,
> Werner


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to