Example: lr_eval_string_ext_free
In the following example, the lr_eval_string_ext_free function frees a buffer allocated by lr_eval_string_ext during correlation.
/* Original URL/
web_url("Response_1.dat",
"URL=http://209.88.184.66/SmWeb/Data/S_DFFA13B8DFB711D3AA6D009027E00675/Response_1.dat",
"RecContentType=application/octet-stream",
"SupportFrames=0",
LAST );
web_save_header(RESPONSE, "headerVar")
web_create_html_param("returnedBuffer", "", "" ) ;
web_submit_data("SmartWeb.asp",
"Action=http:/207.86.104.1/SmWeb/Asp/SmartWeb.asp?App=Web&SmStream@,
"Method=POST",
"TargetFrame=",
"RecContentType=application/octet-stream",
"SupportFrames=0",
ITEMDATA,
"name=?App",
"value=Web",
ENDITEM,
"name=SmStream@Request",
"value=ClassDescription",
ENDITEM,
LAST );
/* Compute the length of the header */
len = strlen(lr_eval_string("{headerVar}") ) ;
/* Get a pointer to the buffer */
lr_eval_string_ext ("{Param1}", 8, &newParam, &prmLen, 0, 0,-1);
// Save the buffer address
newParamAdr = newParam;
/* Retrieve the data from the buffer */
newParam += (len + 9) ; /* move the length of the header + 9 bytes */
fileLocationLength[0] = newParam[0] ; /* read the length of the buffer
fileLocationLength[1] = newParam[1] ; /* the first two bytes are relevant to us.. */
fileLocationLength[2] = 0 ;
fileLocationLength[3] = 0 ;
fileLocationLengthASCII = (short*)(&fileLocationLength[0]) ; /* cast this to a short* to be sure we only read two bytes */
newParam += 2 ; /* Move the pointer in the stream to the beginning of the actual string */
for(i=0, j=0 ; i <= *fileLocationLengthASCII; ++i)
if( ! memcmp( newParam, "\r\n", 1 ) ) { /* Copy the new string into a char* called info */
memcpy(info[j], newParam[i], 1) ; /* copy only ASCII characters and no Nulls */
++j ;
}
/* We now have a string, URL, which is the value we need for the next call. */
char* URL = strcat("URL=http://207.86.104.1", info) ;
web_url("Response_1.dat",
URL, /* this string now holds the correlated value */
"RecContentType=application/octet-stream",
"SupportFrames=0",
LAST );
lr_eval_string_ext_free(newParamAdr); /* free the buffer*/