CoCoA:Print On

From ApCoCoAWiki
(Redirected from ApCoCoA-1:Print On)

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>