Hi, Mark.
Thanks for your prior reply; it was a big help.
I am finally working on displaying data to a web page. I have figured out the various levels of indirection that ultimately invoke fnInsertString(ptrBuffer, usTxLength, usLengthToSend). As written, in fnInsertString(), the value of usTxLength is used only to see if it's zero or not, to decide whether the function was called as a result of £v or £H.
I have a situation where I have several identical objects of a couple of different types to monitor, with a couple of different kinds of values, so I'd like to have the HTML embed the ID of the object and its parameter following the £ that indicates a field to be replaced with data. I understand that I could use £HXY for this, but I'd like to have additional possibilities, not just H. I'd like to use £JXY to display the Y parameter of the object number X of type 1 and £KXY to display the Y parameter of the object number X of type 2, etc.
My suggestion is this: why not change usTxLength to usFieldCode, where the various field codes are
v - for value (i.e., as currently used)
H - for dynamic content (the current stub)
and then any other codes I care to insert that are not already used.
I could simply add
#define WEB_INSERT_OBJECT1 'J'
#define WEB_INSERT_OBJECT2 'K'
// etc.
to config.h just after the definition of WEB_PARSER_START.
This collapses the two calls to fnInsertValue() that invoke fnInsertString() in fnWebParGenerator() to one, giving
unsigned short usFieldCode; // character following £ identifies type of field, e.g., v for value
// ...
usFieldCode = (unsigned short)*ptrBuffer++;
switch (usFieldCode) { // check which of our fields this is
// ...
case WEB_INSERT_STRING: // to insert value string field
case WEB_INSERT_DYNAMIC: // to insert dynamic HTML
case WEB_INSERT_OBJECT1: // insert string for objects of type 1
case WEB_INSERT_OBJECT2: // insert string for objects of type 2
// etc.
if (fnInsertValue) {
cInsertString = fnInsertValue(ptrBuffer, usFieldCode, &usInsertLength); // allow application to insert its own string
}
break;
and the test near the top of fnInsertString() is based on the code of the field, usFieldCode, rather than whether usTxLength is zero.
I've programmed this, and it appears to work.
What I don't know -- and this is the reason for this lengthy query -- is whether it's necessary to worry about the length of the resultant string. I'd even be willing to guarantee that it remains shorter than MAX_SIMPLE_INSERT. Specifically, will fnWebParGenerator() handle the possibility that the result will not fit in the space available in the current TCP frame? I note that in the case of £vXY, this must already be the case. Put another way, why was the value usTxLength passed in to the function fnInsertString() beyond acting as a flag for one of two behaviors?
Thanks,
Richard
P.S. in the various places where the code returns cNoEntry, the length is set using *usLengthToSend = sizeof(cNoEntry) - 1;. This has the effect of chopping off the final '-' from the message.