[eclipse-clp-users] R: How to create a EC_word/string from an array?

From: Giuseppe Di Guglielmo <giuseppe.diguglielmo_at_...95...>
Date: Fri, 17 Oct 2008 07:19:58 +0200
Dear Kish,
in the Section Decomposing ECLiPSe terms in C++ of the Embedding and
Interfacing Manual:
http://87.230.22.228/doc/embedding/embroot067.html
there are some function to convert a EC_word to string, long, double types.

I'd like to assign the array to a EC_word and then if possible convert it to
a C++ string.

At the moment the following C++ code fails, I assume it is due to the
conversion to C++ which never succeeds:

EC_word head;
EC_word tail;
char**  as_string;
long    as_long;

if ( (X.is_list( head, tail ) == EC_succeed) ) {

	std::cout << "X!" std::endl;

} if ( (X.is_long( &as_long ) == EC_succeed) ) {

 	std::cout << "X = " << as_long << std::endl;

} if ( (X.is_long( as_string ) == EC_succeed) ) {

 	std::cout << "X = " << std::string( as_string ) << std::endl;

} else {

	std::cout << "FAIL!" << std::endl;
	exit(1);

}

So I thought to use something like
print_obj(Obj) :- dim(Obj, [N]), ( for(J,1,N), param(Obj) do Ob is Obj[J],
printf("%1d", Ob) ), nl.
to create a EC_word (as string) and the retrieve it as a C++-string.

I hope the problem is clear now,
thanks,
Giuseppe

> -----Messaggio originale-----
> Da: Kish Shen [mailto:kisshen_at_...5...]
> Inviato: venerd́ 17 ottobre 2008 4.48
> A: Giuseppe Di Guglielmo
> Cc: eclipse-clp-users_at_...105...
> Oggetto: Re: [eclipse-clp-users] How to create a EC_word/string from an
> array?
> 
> Giuseppe Di Guglielmo wrote:
> > Dear all,
> > the function
> >
> > print_obj(Obj) :- dim(Obj, [N]), ( for(J,1,N), param(Obj) do Ob is
> Obj[J],
> > printf("%1d", Ob) ), nl.
> >
> > permits to print on console the values of an array. How can I append all
> > this value to create a EC_word?
> >
> > Best regards,
> > Giuseppe
> >
> > ------------------------------------------------------------------------
> ----
> > Giuseppe Di Guglielmo       Dept. of Computer Science - University of
> > Verona
> >                                Strada le Grazie, 15 - 37134 Verona -
> Italy
> >
> > Phone Office:   +39 045 8027049         Fax:    +39 045 8027068
> > Phone Home:     +39 045 6152251         Mobile: +39 347 0493371
> >
> > WWW: http://profs.sci.univr.it/~diguglielmo
> >
> > email: giuseppe.diguglielmo_at_...95...
> > email: diguglielmo_at_...96...          Skype: giuseppe.diguglielmo
> >
> Hi Giuseppe,
> 
> I am not quite sure what you are asking. An array is simply a structure
> (the array notation just allow structures to be used more like
> conventional array syntax), and you can pass a structure to your C++ as
> an EC_word. You don't need to construct it if the structure already
> exist in ECLiPSe.
> 
> Cheers,
> 
> Kish
> 
> 
> --
> This e-mail may contain confidential and privileged material for the
> sole use of the intended recipient. Any review, use, distribution or
> disclosure by others is strictly prohibited. If you are not the intended
> recipient (or authorized to receive for the recipient), please contact
> the sender by reply e-mail and delete all copies of this message.
> Cisco Systems Limited (Company Number: 02558939), is registered in
> England and Wales with its registered office at 1 Callaghan Square,
> Cardiff, South Glamorgan CF10 5BT.
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
Received on Fri Oct 17 2008 - 05:20:06 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST