Parameter Set or String (Func. Param. Type)

Prev Next

Introduction

Various functions accept either parameter sets or strings when expecting one or multiple strings, for example file names as supported by various file functions. The rules are described below Whenever a function expects a function parameter for table columns, the following types are supported and automatically put into parameter sets.

Type Description Example
Quoted strings The content of the entire string is interpreted as one single string value
Empty strings "" are treated as they are.
"Last,First Name" is such an example
Softquoted strings The content of the entire string is interpreted as one single string value
Empty strings '' are treated as they are.
'Last,First Name' is such an example
Parameter set Parameter sets can contain any number of values
Empty sets {} provide zero values.
{ Last Name, First Name, "Value [EUR]", 123 }



The following code example demonstrates this parameter type ruling using a user-defined function. The user-defined function gets all values in form of parameter sets and prints the contents.

  define procedure( demonstrate, { { parameter 1, to parameters } }, 1, unlimited )
  {
      for (i[] = 1, i[] <= parameter count[], i[]++)
      {
      var name[] = 'parameter ' + str(i[]);
          print( var name[][], "  (", var name[][]{}," items) " );
      }
      echo;
  }

  demonstrate( A, B );
  demonstrate( Hello World,  Hello   World  ); // Both are same
  demonstrate( "A,B", " A, B " ); // Both are different
  demonstrate( 'A,B', ' A , B '); // Both are same
  demonstrate( "", '', '  ' ); // Blank, empty, empty
  demonstrate( 'Hello World,  Hello   World  ,"   Hello   World   "');
  demonstrate( { Hello   World, '  Hello   World  ',"   Hello   World   "}); // Note the differences

  echo;

  define additional procedure( demonstrate 2, demonstrate,
      { { parameter 1, to parameters members to string } }, 1, unlimited );
  
  demonstrate   ( { 1, 2, '3' } );
  demonstrate 2 ( { 1, 2, '3' } ); // Note: All numbers are converted to strings
{'A'}  (1 items) {'B'}  (1 items)
{'Hello World'}  (1 items) {'Hello World'}  (1 items)
{'A,B'}  (1 items) {' A, B '}  (1 items)
{'A,B'}  (1 items) {' A , B '}  (1 items)
{''}  (1 items) {''}  (1 items) {'  '}  (1 items)
{'Hello World,  Hello   World  ,"   Hello   World   "'}  (1 items)
{'Hello World','  Hello   World  ','   Hello   World   '}  (3 items)

{1,2,'3'}  (3 items)
{'1','2','3'}  (3 items)
Try it yourself: Open LAN_Features_parameter_set_or_string.b4p in B4P_Examples.zip. Decompress before use.