type, subtype

Prev Next

Function Names

type, subtype, vtype, vsubtype

Description

The function type returns one of the following string values:

  • numeral
  • string
  • boolean
  • date
  • set (Only applicable for function names type and subtype. For the other two functions vtype amd vsubtype, the vectorization rule applies. See below.
  • void

The function subtype returns one of the following string values:

  • numeral (contains an original text representation)
  • plain numeral (contains no text representation)
  • softquoted string, (softquoted string)
  • quoted string (quoted string)
  • boolean
  • date (contains an original text representation)
  • plain date (contains no text representation)
  • set
  • void



Vectorization: The function names beginning with the prefix v support vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.
Note:For these functions, you need add the prefix letter 'v' in front of the function name. Otherwise the function recognizes a set and attempts to process sets and not strings.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
all types Value

Value to be converted as described above. For function names vtype and vsubtype, vectorization applies if a set is provided.

Return value

TypeDescription
string
set
Type of value

See main function desription. If vectorization is used, then a set containing the results is returned.

Examples

               a[num 1] = 1;
               a[num 2] = a[num 1] + 0;
               a[lit 1] = Plain text;
               a[lit 2] = 'A softquoted string';
               a[lit 3] = "A quoted string";
               a[lit 4] = soft( a[lit 3] );
               a[date] = date(today);
               a[bool] = true;
               a[pset] = { 1,2,3 };
               a[void] = null();

               for all variables( a[], value[], counter[], name[] )
               {
                       echo( name[], ": ", value[], " --> ", type( value[] ), ", ", subtype( value[] ) );
               }

Output

bool: true --> boolean, boolean
date: 2024-10-19 --> date, plain date
lit 1: Plain text --> string, softquoted string
lit 2: A softquoted string --> string, softquoted string
lit 3: A quoted string --> string, quoted string
lit 4: A quoted string --> string, softquoted string
num 1: 1 --> numeral, numeral
num 2: 1 --> numeral, plain numeral
pset: {1,2,3} --> set, set
void: # Invalid Value # --> void, void
Try it yourself: Open LIB_Function_type.b4p in B4P_Examples.zip. Decompress before use.