fdescribe

Describe a variable into a file.

Syntax

status = fdescribe ( variable , fileHandle ) ;

Arguments

list variable

handle fileHandle

Return Value

str status

Exceptions

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

Description

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

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

To execute the example below, press or modify the example to try different variations.

Related Links

describe , sdescribe , xdescribe , xfdescribe , xsdescribe