Questions? Search our site or call 1-800-722-6004

Update an HTML Web Page to Provide Real-time Data

Suppose that you had an instrument that provided some sort of data on a regular basis and you wanted to update an HTML file with new data each time it was transmitted from the instrument.

One way to do this is to set up the Wedge in "Send Keystrokes" mode and have it send keystrokes containing HTML code along with the data from the instrument to the NotePad program.

In this case we first set up the Wedge so that each time it receives new data from the instrument it opens the NotePad program and automatically loads in an existing HTML document. We also define the "Record Preamble Keystrokes" in the Wedge that will select all the text in the NotePad window and overwrite it with all the HTML code that will go before the actual data from the instrument. Finally we define the "Field Postamble Keystrokes" after the last data field defined in the Wedge to contain all the HTML code that will go after the actual data. We also need to add in a few additional keystrokes that will save the new HTML file overwriting the old one and finally close the NotePad program.

When you select "Send Keystrokes" from the mode menu in the Wedge, it will ask you for the "Application Title Bar Text" and the "Command Line" for the application that you want to receive the keystrokes. In this case you would enter: NotePad for the Application Title Bar Text and then specify: Notepad.Exe mypage.htm where "mypage.htm" is the full path and file name for the HTML file that you want to update. When you specify a file name on the command line used to launch NotePad, NotePad will automatically load in the specified file.

The following HTML code is a minimal example of what you might need in your HTML document.

(The META command on the third line will cause most browsers to automatically refresh the page every 5 seconds. Please refer to your favorite HTML code reference for an explanation of the HTML tags in the following code.)

<TITLE>Real Time Data Provided By Software Wedge</TITLE>
<H1>Serial Data goes here maybe</H1>

To get the Wedge to write the above code you would use the following text in the "Record Preamble Keystrokes" in the Wedge:

%ea<HTML>~<HEAD>~<META HTTP-EQUIV="Refresh" CONTENT=5>~<TITLE>Real Time Data Provided By Software Wedge</TITLE>~</HEAD>~<BODY>~<H1>

The keystrokes %ea means "Alt+e a" and will cause Notepad to select all the text in the Notepad window. The tilde (~) characters cause the Wedge to send "Enter" keystrokes. The tilde is equivalent in meaning to the word "{ENTER}" when defining preamble and postamble keystrokes in the Wedge.

The "Field Postamble Keystrokes" after the last data field defined in the Wedge would be:


The keystrokes %fx mean "Alt+f x" and when sent to Notepad, cause it to select "Exit" from its File menu. The final tilde (Enter keystroke) is required because Notepad will prompt you with a message box asking you if you want to save changes to the file. If the Enter key is pressed in response to the prompt, Notepad overwrites the existing file with the new data.

Each time that the Wedge receives new data from the device, it will launch Notepad automatically loading in the old HTML file and then it overwrites the file with the same HTML code but with new data from the instrument. Finally it unloads Notepad and saves the new file and overwriting the old one. The process will repeat itself each time you receive new data from the instrument.

Categories: Tutorial / How-To, Data Collection, Serial (RS232), WinWedge

Last Updated: 2013.08.30

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)