Re: put_code

[email protected]
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Muito obrigado Salvador,
it seems that can help me very much.
I am going to try it in my application and I'll let you know.

Thanks again
     Massimo

Citando Salvador Pinto Abreu <[email protected]>:

> On Nov 1, 2012, at 11:30, [email protected] wrote:
>
>> I am trying to automatically generate PPM P5 files.
>> In order to write the binary part of the files, I am using
>>
>> put_code/1
>
> maybe, considering you are building a non-text file, you'd be better  
>  off having Prolog use a binary stream, in which case you'd be using  
>  the put_byte/1 built-in.
>
> consider this, for instance:
>
> 11:56:56$ gprolog
> GNU Prolog 1.4.1
> By Daniel Diaz
> Copyright (C) 1999-2012 Daniel Diaz
> | ?- open(foo, write, _FOO, [type(binary), alias(foo)]),
>      set_output(foo),
>      put_byte(0), put_byte(1), put_byte(2), put_byte(3),
>      close(foo).
>
> (1 ms) yes
> | ?- halt.
>
> 11:57:05$ od -b foo
> 0000000   000 001 002 003
> 0000004
> 11:57:10$ ls -l foo
> -rw-r--r--  1 spa  staff     4B Nov  1 11:56 foo
> 11:57:19$
>
> hope this helps
> -salvador
>
>



----------------------------------------------------------------
Massimo De Gregorio
Research Scientist
Istituto di Cibernetica "Eduardo Caianiello" - CNR
Via Campi Flegrei 34
Comprensorio "A. Olivetti" - Ed. 70
80078 Pozzuoli (NA) - ITALIA
Tel. (+ 39) 0818675151
Fax: (+ 39) 0818675158
Skype: massimo.de.gregorio
E-mail: [email protected]
----------------------------------------------------------------

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.