This function composes URL-encoded form strings similar to those specified in the dclform section. The resulting string is commonly used to add parameters to URLs or to build up messages to be sent with WebUrlPostBin.
WebFormBuild appends a pair of sLeftVal "=" sRightVal at the end of sForm. If sForm is NULL when calling WebFormBuild, "&" is added before adding the pair of sLeftVal "=" sRightVal to the result of the previous call.
WebAPI.bdh
WebFormBuild( out sForm : string allownull, inout nMaxFormLen : number, in sLeftVal : string allownull, in sRightVal : string allownull ): boolean;
true if the form is generated successfully
false otherwise
Parameter | Description |
---|---|
sForm | Target string to be filled; NULL value allowed |
nMaxFormLen | Variable containing the maximum length of target string. On return it will contain the current length of the string written to sTarget. |
sLeftVal | Left value of form parameter, which may be NULL |
sRightVal | Right value of form parameter, which may be NULL |
If sLeftVal/sRightVal is not NULL and not empty, it is encoded using the function StrFormEscape.
If sLeftVal is NULL or empty, only sRightVal is added to sForm.
Is sRightVal is NULL or empty, sLeftVal and "=" is added to sForm.
dcltrans transaction TWebFormBuild var sForm : string(1000); nFormSize : number; bOk : boolean; begin sForm := "http://www.MyCompany.com?"; nFormSize := sizeof(sForm); bOk := WebFormBuild(sForm, nFormSize, "country", "USA"); bOk := WebFormBuild(NULL, nFormSize, "jack@datz.com", NULL); bOk := WebFormBuild(NULL, nFormSize, NULL, "46&kj%= jd"); WebUrl(sForm); write("form = "); write(sForm); writeln; sForm := ""; nFormSize := sizeof(sForm); bOk := WebFormBuild(sForm, nFormSize, "TestLeftVal", "TestRightVal"); WebUrlPostBin("http://www.company.com", sForm, nFormSize, "text/html"); write("form = "); write(sForm); writeln; end TWebFormBuild;
form = http://www%2EMyCompany%2Ecom?country=USA& jack%40datz%2Ecom=&46%26kj%25%3D+jd form = TestLeftVal=TestRightVal
WebForms03.bdf