How to Use HTML Dialog Extender Functions with Variables
Keywords: HTML dialog variables
Question:
Instead of using normal dialog to prompt users for input, I created a HTML dialog table with fancy background. I was able to use frontpage98 to set the default value and allow users to edit it and click the summit button and then update to a MsAccess database using ODBC. I would like to be able to assign dynamic default value to the HTML Dialog table. Eg. getting User Name, Computer Name, today's date and allow user to enter only their phone number. It is not a problem if I used the standard dialog box.I am not clear of how to insert the winbatch define variables into HTML. Can you give me a few hints?
Answer:
Download the latest version of the HTML Dialog extender and read the help file (unless you downloaded it recently).The Trick is to look up the values in the WinBatch script, and incorporate these values when you make the HTML. *Assuming* you are making your HTML with the same way most of the examples to, using the FixupHtml subroutine and the BinaryTag stuff, then you would add something like...
username=wntGetuser(@DEFAULT)in your WinBatch code and then in your html template file:{{VALUE username}}where the username should go.Mostly you have to get close with Frontpage, then do a little hand editing to stick some of the {{VALUE username}} tags in.
The trick is that you have to re-write the html file in the script. If you are using a static, non-changing html file, the script must update the html file and then display the updated file.
There are many ways to update the file, but we have a fast one using the BinaryTagxxx functions. Perhaps see some of the examples shipped with the HTML extender.
So here's a brief overview:
That's it. It's simple.
- In your HTML file, enclose any text to be replaced in unique text designated for that purpose. In this example, I will use "{{" and "}}," the same enclosures used in the HTML dialog examples that come with the extender.
- In your WinBatch code, place the HTML file into RAM:
htmlfile = "web_page.htm" RAMhtml = BinaryAlloc(FileSize(htmlfile) + 1024) ;1,024-byte buffer BinaryRead(RAMhtml,htmlfile)
- In your WinBatch code, initialize a search variable (I will use the variable query), specifying the enclosure text:
query = BinaryTagInit(RAMhtml,"{{","}}")
- Use BinaryTagFind() to find any text enclosed in "{{}}," then use BinaryTagExtr() to determine what is actually between "{{" and "}}":
While @TRUE query = BinaryTagFind(query) If (query == "") Then Break ;No more "{{}}" found found = BinaryTagExtr(query,0)
- Determine the replacement text depending on the value of found, i.e. what you get between "{{" and "}}" (in the next step, this replacement text has been assigned to a newtext variable).
- Replace the text:
BinaryTagRepl(query,newtext) ;This overwrites the text and the "{{}}" EndWhile
- Write the changed RAM data over the old HTML file:
BinaryWrite(RAMhtml,htmlfile) BinaryFree(RAMhtml)
Article ID: W12524Filename: How to Use HTML Dialog.txt