[Ecls-list] Printing to a string

Dean O'Connor dean.oconnor at ite.com.au
Sun Jan 15 22:03:01 UTC 2006


try this, equivalent to the lisp format statement I guess:

    cl_object myarray = c_string_to_object("#(1 2 3)");
    cl_object cl_str = cl_format(3, Cnil, make_simple_string("~a~%"), 
myarray);
    std::cout << cl_str->string.self;

worked for me :)

Cheers
Dean.

David Creelman wrote:

>Hi Dean,
>
>Thanks.
>
>Yes, that works for me too, but I'm wanting to put the string from the
>print up onto a GUI, not standard output. I thought
>ecl_string_pointer_safe would do that (assuming that cl_print returns a
>string..).
>
>Any idea how I'd get the string back ?
>
>Cheers
>David
>
>On Mon, 2006-01-16 at 15:37 +1100, Dean O'Connor wrote:
>  
>
>>I tried your source in Windows MSVC (see below) and the cl_print works ok.
>>ie. I see #(1 2 3) displayed on the screen.
>>
>>However, the ecl_string_pointer_safe line crashes for me.
>>
>>I guess the cl_print (in this case) will return a object of type vector 
>>(same as myarray).
>>
>>Not too sure what you are trying to do with ecl_string_pointer_safe, and 
>>I can't find any doco on it, but I don't think you need it if you just 
>>want to print an object to the screen.
>>Just lose the last line I think ??
>>
>>The cl_print will print most/all objects to screen AFAIK.
>>
>>
>>Cheers
>>Dean.
>>
>>#include "ecl.h"
>>
>>int main(int argc, char* argv[])
>>{
>>   cl_boot(argc, argv);
>>   cl_object myarray = c_string_to_object("#(1 2 3)");
>>   cl_object cl_str = cl_print(1, myarray);
>>   cl_object str = ecl_string_pointer_safe(cl_str);   // Crashes here 
>>for me :)
>>
>>    return 0;
>>}
>>
>>David Creelman wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>I'm wanting to generically print an atom, symbol, list, string, etc out
>>>to a string that I can then display on the screen (a la REPL).
>>>
>>>I thought cl_print would do this for me, but ECL crashes when I call the
>>>following:-
>>>
>>>	cl_object myarray = c_string_to_object("#(1 2 3)");
>>>	cl_object cl_str = cl_print(1, myarray);	// This crashes.
>>>	str = ecl_string_pointer_safe(cl_str);
>>>
>>>What am I doing wrong here ?
>>>
>>>Can this be done or should I be doing my own interpretation of types ?
>>>
>>>Regards
>>>David
>>>
>>> 
>>>
>>>      
>>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
>>for problems?  Stop!  Download the new AJAX search engine that makes
>>searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>>_______________________________________________
>>Ecls-list mailing list
>>Ecls-list at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/ecls-list
>>    
>>




More information about the ecl-devel mailing list