TCPmaker : Visual Tour    How Variables and Controls Work Together  

As we'll see in the next section, sending a Numeric Variable from the PC to the device follows a similar process.  It's just a little different because a Numeric Variable displays a floating point value on the PC browser, but only communicates a scaled integer equivalent to the micro, using the automatic scaling properties mn, mx, pn, and px of the Numeric Variable. (That way, the micro code doesn't have to do any floating point math.)

Remember, this scaling process happens automatically in run.swf: you don't need to add any code to make this happen.

Here is what you need to actually do:

  • In the Visual Page Designer, create a Numeric Variable to hold the data item. Give it a unique (and meaningful) name and Id.
  • Set the automatic scaling properties mn, mx, pn, and px of this Numeric Variable.
  • Also in the Visual Page Designer, create a suitable Control (e.g. a Horizontal Slider) that can change this Numeric Variable.
  • Associate the Variable with the n property of the Control, by selecting the name of the variable from the dropdown list.
  • Save your layout, and let TCPmaker generate your code.  The code generator will create an integer variable of this name in your micro source code (to hold the integer equivalent of your Numerical Variable), and generate an Event Handler for this Numeric Variable, that will automatically be called any time the state of the Control is changed.
  • All you need to do is add a little code to that Event Handler to make use of the new integer equivalent value of the Numeric Variable that was just sent to the device.

 

Pretty simple!

 

 

 

 
  

7 of 12
Copyright Notice and Author Information