CoCoA:Print On

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Print On

print to an output device

Description

This command prints the value of expression E to the device D.

Currently, the command can be used to print to files, strings, or the

CoCoA window. In the first two cases, the appropriate device must be opened with <ttref>OpenOFile</ttref> or <ttref>OpenOString</ttref>.

Example

  D := OpenOFile(<quotes>my-test</quotes>);  -- open <quotes>my-test</quotes> for output from CoCoA
  Print <quotes>hello world</quotes> On D;   -- print string into <quotes>mytest</quotes>
  Close(D);  -- close the file
  D := OpenIFile(<quotes>my-test</quotes>);  -- open <quotes>my-test</quotes> for input to CoCoA
  Get(D,3);  -- get the first three characters (in Ascii code)
[104, 101, 108]
-------------------------------
  Ascii(It);  -- convert the ascii code into characters
hel
-------------------------------
  Close(D);

See <ttref>OpenOFile</ttref> for an example using output strings. For printing to the CoCoA window, just use Print E which is short for Print E On DEV.OUT.

Syntax

Print E:OBJECT On D:DEVICE

Introduction to IO

OpenIFile

OpenOFile

OpenIString

OpenOString

Print

PrintLn

   <type>io</type>
   <type>printing</type>