WebFormExpand Function

Action

This function converts forms specified in the dclform section to URL-encoded form strings. The resulting string is commonly used to add parameters to URLs or to build up messages to be sent with WebUrlPostBin.

Include file

WebAPI.bdh

Syntax

WebFormExpand( in  fForm       : form,
               out sExpForm    : string,
               in  nMaxExpForm : number,
               in  bCalcRandom : boolean): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
fForm Form declared in the dclform section.
sExpForm String variable receiving the URL encoded form string.
nMaxExpForm Length of the string receiving the URL encoded form string. If it is set to STRING_COMPLETE all available data is stored in sExpForm.
bCalcRandom Specifies whether to calculate the random variables part of the form.

Example

dclrand
  nrPhone: RndUniN(5550000..5559999);

dcltrans
  transaction TMain
  var
    sForm : string(100);
    i : number;
  begin
    for i := 1 to 5 do
      // calculate new random values each time
      WebFormExpand(FORM_01, sForm, STRING_COMPLETE, true);
      write(sForm); writeln;
    end;

    // do not calculate new random values
    WebFormExpand(FORM_01, sForm, STRING_COMPLETE, false);
    write(sForm); writeln;
  end TMain;

dclform
  FORM_01:
    "name" := "John",
    "phone" := nrPhone;

Output

name=John&phone=5556872
name=John&phone=5558055
name=John&phone=5559284
name=John&phone=5558252
name=John&phone=5551969
name=John&phone=5551969

Sample scripts

WebForms04.bdf