Pack1616 - Pack Two 16bit Integers into One 32bit Integer

Usage

  integer = Pack1616 ( lhinteger rhinteger )

Parameters

  integer Resulting 32 bit integer point.
  lhinteger Low order 16 bits becomes high order of resulting number.
  rhinteger Low order 16 bits becomes low order of resulting number.

Description

This module packs two numbers into a single 32-bit number. The primary use of these modules is in the creation of unique binding points for very large models.

Also see the BindEval option under the Dimension command when declaring dimensions. The Flatten module is a generalized module for flattening multiple points onto a single point.

Examples

  Pack1616(3 4) results in Int:196612
  Pack1616(0 -1) results in Int:65535 (the second argument is truncated to 16 bits)

Parse - Generalized Parser / Tokenizer

Usage

  result = Parse ( source tagarg ... )

Parameters

  result The result depends on the arguments.
  source What is to be parsed. This must be either a string or list.

Tagged Arguments

  As::option Parses the first argument according to option. The allowed option values are-
  • Binary to parse as an unsigned binary integer;
  • ASCII to parse as ASCII. V4 converts many UNICODE character to the 7-bit 'equivalent'. For example '™' is converted to '(tm)', 'À' to 'A'.
  • CNumLiteral to parse as a C numeric integer literal;
  • Currency parses the first argument as a currency value and returns the result as a point on Dim:Num. This differs from coercing to an integer or real in that it ignores many characters: spaces, commas, currency symbols, etc. It also accepts leading and trailing negative signs and negative numbers enclosed in parentheses;
  • Decimal to parse as a signed decimal integer number;
  • Email to parse as an email address;
  • Hexadecimal to parse as an unsigned hexadecimal integer number;
  • JSON to parse as a JSON string (see also JSON);
  • Octal to parse as an unsigned octal integer;
  • Real to parse as a signed floating point number;
  • Telephone to parse a a telephone number;
  • Zipcode to parse as a 5 or 5+4 zipcode.
  Exclude::list Exclude the list of nodes from the XML entry being parsed. All nodes in the list and all child nodes beneath those nodes are excluded from the resulting parsed XML tree.
  HTML::options Parse the source as HTML. The options are identical to those of Token.
  Include::option The V4 XML parser, by default, ignores or excludes schema and attribute information when parsing an XML message. This is information embedded within the opening XML tag. This information may be included by specifying this option. If option is SCHEMA then schema information is included. If it is ATTRIBUTES then attribute information is included. See description below for more information on schema and attribute information.
  ListOf::option Returns a list based on option. Currently only PUNCTUATION is supported as a option and it returns a list of the standard names V4 uses for punctuation charcters and punctuation tokens.
  Maximum::num Parse up to a maximum of num XML tokens and then quit. This is useful when testing extremely large XML files.
  Nodes::num Use num as a hint to the final number of nodes expected in the XML tree. This option will increase the efficiency of parsing very large XML files.
  Token::options Parse the source according to the options. Currently supported options are: EndOfLine to return the end-of-line as a token; LowerCase to return keywords in lower case, if not given all keyword tokens are passed as seen; Negative to parse constructs of the form '-nnnn' as a single negative number token, if not specified then the minus sign is passed as a separate token; Space to return spaces as tokens, Uppercase to convert all keyword tokens to upper case otherwise keywords are passed as seen.
  Trace::num Output a trace status line every num tokens parsed.
  Tree::dim Create a tree based on dim when performing an XML parse.
  XML::options Parse the source as XML. The options are identical to those of Token.

Tagged Results

  HTML? Parse the source as HTML.
  Token? Parse the source and return as a list of tokens.
  XML? Parse the source as XML.

Description

This module is used to parse a string or list of strings. It currently will return a list of tokens or in the case of XML parsing create a V4 tree (see Tree module). Integer tokens are returned as points on Dim:Int, real numbers on Dim:Num, strings on Dim:Alpha, keywords on Dim:NId, and punctuation on Dim:UV4.

Note that a file can be parsed by converting it to a list with the ListOf option in the OSFile module.

Schema and attribute information may also be included in the XML parse tree. This information is handled as child nodes just like other child nodes of an element. However the values are not represented as strings but as lists. In this way, schema/attribute information can be separated from other child nodes of an element.

When the result is a list of tokens, a lazy-list is returned. If an explicit list is required then you must enumerate through the result. See the example below.

  Parse(OSFile(File* ListOf?) Trace::Int:250000 Tree::Dim:HTree Exclude::[ExcludeList] XML?) Parse the contents of the file and create an internal XML tree
  Context::EnumCL(Parse([parseString] Token?) Shell::Dim:S @S*) Add list of parsed tokens to context

PCChg1/2 - Calculates Percentage Change

Usage

  pc = PCChg1/2 ( num1 num2 tagarg )
  pc = PCChg1/2 ( num1 num2 tagarg )

Parameters

  pc The resulting percentage change.
  num1 The first argument.
  num2 The second argument.
  tagarg Optional tagged arguments

Tagged Arguments

  Error::n Return n if an error occurs (e.g. divide by 0).
  Round::n Round the results to n decimal places if n is positive, or to the nearest power of 10 if n is negative.

Description

These two modules calculate percentage change. PCChg1 calculates the change based on the first argument ((num2-num1)*100/num1) while PCChg2 calculates on the second ((num2-num1)*100/num2). If the denominator is zero (num1 if PCChg1 or num2 if PCChg2) then these modules return 0.

Examples

  PCChg1(30 35) Num:16.667
  PCChg2(30 35) Num:14.2857
  PCChg2(30 35 Round::2) Num:14.29

Percent - Percentage of One Number to Another

Usage

  resnum = Percent ( npt1 npt2 )

Parameters

  resnum The resulting numerical point. Note that the dimension of the result is always the dimension of the second argument to the module.
  npt1 A numerical point.
  npt2 A numerical point.
  tagarg Optional tagged arguments

Tagged Arguments

  Error::n Return n if an error occurs (e.g. divide by 0).
  Round::n Round the results to n decimal places if n is positive, or to the nearest power of 10 if n is negative.

Description

This family of modules implements the basic arithmetical functions. The Percent module returns the percentage of the first argument to the second. If either argument is 0 then 0 is returned.

Examples

  Percent( Real:5 15 ) Int:33
  Percent( 5 Real:15 ) Real:33.3333
  Percent( 5 Real:15 Round::-1 ) Real:30

Plus - Add Two or More Numbers

Usage

  resnum = Plus ( npt1 npt2 ... )

Parameters

  resnum The resulting numerical point. Note that the dimension of the result is always the dimension of the second argument to the module unless the second argument is a point on the Int dimension. In this case the result is the dimension of the first argument.
  npt1 A numerical point.
  npt2 A numerical point.

Description

Plus returns the sum of its two or more arguments.

Examples

  Plus( Real:5 15 ) Real:20
  Plus(UDate:12/31/99 1) UDate:000101 (where 00 refers to the year 2000!)
  Plus( 5 Real:15 ) Real:20

Project - Project Point Onto Different Dimension

Usage

  value = Project ( resdim srcdim tagarg )
  value = Project ( resdim point )
  value = Project ( respoint srcdim.. )
  value = Project ( respoint srcpoint )

Parameters

  value The result of the projection. If the call is to define a projection then the result is undefined.
  resdim The target dimension (i.e. the resulting dimension of a projection).
  srcdim The source dimension (i.e. the dimension of the originating point).
  tagarg One or more of the tagged arguments below.
  respoint The resulting point on target dimension.
  srcpoint The source point on the source dimension.

Tagged Arguments

  Area::logical If logical is TRUE then save the projections in an area. If FALSE then maintain the projection information in an in-memory cache. This option must be TRUE for one-to-many projections.
  Cache::bytes Set the internal cache size to bytes. Normally this is not necessary as V4 will automatically adjust the cache size. A slight performance gain may be found by presetting the size.
  Error::string Defines a error message string to be output when an undefined projection is attempted.
  Length::bytes The maximum length of a source point. The default is 12 bytes.
  Point::point Defines a point to be returned on an undefined projection.
  Unique::logical If TRUE (default) then a one-to-one projection is maintained. If FALSE then a one-to-many projection is allowed. Note that the Area option must be set to Logical:True for one-to-many projections.
  Update::logical If TRUE then update the projection with the Point value. If FALSE then do not automatically update the projection on an error.

Tagged Results

  Define? This argument is used to determine whether or not a projection has been defined between two dimensions. Logical:True is returned if the projection is defined. The module fails if no projection is defined.
  Remove? Removes or deletes the previously defined projection between resdim and srcdim. This is only valid on locally cached projections (Area:FALSE).

Description

The Project module is used to both define and determine the projection of a point on one dimension to another. Projections are an efficient way of mapping from one type of value to another. Projections can be implemented as a in-memory hashed tables or on a permanent basis as an multi-level index in a V4 area. Projections are not contextual! The projections can be expressed in one of two ways. First is explicitly with the Project module. Second is with the dim:=point construct which is converted to Project(Dim:dim point).

Many projections are implemented by the V4 runtime system. Projections are defined between most of the major point types. Projections are also defined between dimensions associated with time.

If the target dimension has an acceptor function associated with it and the source point is a character string, then the acceptor function will be invoked. Use the MakeP module to create points bypassing any acceptor logic.

  Project(Dim:UMonth UDate:020301) results in UMonth:0203
  Project(Dim:Int Num:1.234) results in Int:1
  Project(Dim:Int Num:1.567) results in Int:2 (rounds)
  Project(Dim:UDate UMonth:0203) results in UDate:020301..020331 (all the days in the month)
  UDate:=UMonth:0203 same as above
  [CalcDim]:=[CellValue] is the same as Project([CalcDim] [CellCalue])
  FALSE:=Student.. is the same as Project(Logical:False Student..)

PRUpd - Update a PointReference Point

Usage

  value = PRUpd ( pointref valpt )

Parameters

  value This module always returns its first argument- pointref.
  pointref The first argument must be a point on a PointReference dimension.
  valpt Any V4 point.

Description

This module updates the static point references by pointref with the point valpt.

Examples

  Dim X PointReference Declare a PointReference dimension
  Context Add MakeP(Dim:X 0) Makes a point reference set to Int:0
  Enum(Int:1..100 @PRUpd(X* {X* + Int*})) Adds all the integers from 1 to 100 into X*
  X* Is a point reference to Int:5050