Skip to content

_xfdescribe

bergsma edited this page Sep 26, 2014 · 5 revisions

#xfdescribe

###Describe as XML a variable into a file.

Syntax

status = xfdescribe ( variable,fileHandle ) ;

Arguments

  1. list variable

A variable or value of any type.

  1. handle fileHandle

A file handle obtained from the fopen() function.

Return Value

str status
  • $ACKNOWLEDGE : The fdescribe function was successful.

The STATUS variable is set to $ACKNOWLEDGE

str status
  • $ACKNOWLEDGE : The fdescribe function was successful.

The STATUS variable is set to $ACKNOWLEDGE

Exceptions

  • %ARGUMENT: Invalid arguments. Usage: status = xfdescribe ( variable,fileHandle ) ;

Description

The describe functions are a means to both display and store variable data.

  • describe displays the variable to stdout
  • fdescribe displays the variable into a file
  • sdescribe displays the variable into another variable
  • xdescribe displays the variable to stdout in XML format
  • xfdescribe displays the variable into a file in XML format
  • xsdescribe displays the variable into another variable in XML format

When a variable is described, it is explicit. For example, the assignment:

**a = 1 ;**

when described, ie; "describe a", is always explicit:

**list 'a' = { 1 } ;**

In another example, the assignment

**a.b.c = 1 ;**

when described, is also explicit:

**list a = {
  list b = {
    list c = { 1 }
  }
} ;
**

The xdescribe function is for generating XML (or HTML). For example:

list html = {
  list body = {
    list h1 = "A story",
    list p = { "The rain in spain" },
    list a = {
      attr ref="http://www.raininspain.com/",
      "Press here"
    }
  }
} ;**

xdescribe html ;

<html>
  <body>
    <h1>
      A story
    </h1>
    <p>
      The rain in spain
    </p>
    <a ref="http://www.raininspain.com/">
     Press here
    </a>
  </body>
</html>**

The xfdescribe() and fdescribe() functions are useful for storage and retrieval of variables. For example:

**h = fopen ( "mydata.dat", 'w" ) ;
fdescribe ( data,  h ) ;
fclose ( h ) ;
.
.
...later read back the 'data'
.
.
h = fopen ( "mydata.dat", "r" ) ;
line = fgets ( h ) ;
*line ;  // Restore 'data'
fclose ( h ) ;**

The fdescribe and xfdescribe functions also work in conjunction with the parse and xparse functions. For example, the above section of code to re-read the 'data' variable could also be accomplished by:

**parse ( "mydata.dat" ) ;**

The xparse function can be used to read an entire html page or a segment of an html page and then display it. For example. this "Description" section comes from a separate document that was read using the xparse() function.

**xparse ( "describe.htm" ) ;
xdescribe ( html.body ) ;
**

Examples

list L = {
  int i = 1,
  float f = 2.6,
  str s = "hello"
};

describe L ;

Related Links

describe
sdescribe
xdescribe
xsdescribe

Clone this wiki locally