IV. RESULTADOS Y DISCUSIÓN
4.2. Evaluación de la concentración y absorción de nutrientes en hojas
To make the form work with PowerSHAPE:
Add the commands that communicate with PowerSHAPE to create a simple helix.
Add a procedure (see page 90)
Link the procedure to the Apply button. (see page 94) Adding the Apply_click() procedure
PowerSHAPE understands the commands used in macros. The best way to work out the commands to use is by recording a macro.
You are strongly recommended to complete the Macro tutorial (see page 51) before creating your own HTML applications
The following are commands from the macro in the Macro tutorial, LET $radius = 10
LET $pitch = 4 LET $numturn = 10
LET $neg_radius = -$radius LET $zheight = $pitch / 4 create curve
THROUGH $radius 0 0
WHILE $numturn {
LET numturn = $numturn - 1
$neg_radius $radius $zheight $neg_radius $neg_radius $zheight $radius $neg_radius $zheight $radius $radius $zheight }
Select
The following steps show you how to convert these commands into vbscript commands
1. In the script section, add the procedure called Apply_click() as shown below.
<script language="VBscript">
// Connect to PowerSHAPE set pshape = Window.external
Sub Apply_click()
//Calculating values for the coordinates neg_rad = - document.helix.radius.value zheight = document.helix.pitch.value /4
//Creating the helix's curve pshape.Exec "Create curve"
pshape.Exec "through"
//First coordinates of the curve
pshape.Exec "abs " & document.helix.radius.value & " 0 0"
//Using a loop to input the coordinates from each turn
Counter = document.helix.turns.value Do Until Counter = 0
Counter = Counter - 1
pshape.Exec neg_rad & " " & document.helix.radius.value & " "
& zheight
pshape.Exec neg_rad & " " & neg_rad & " " & zheight
pshape.Exec document.helix.radius.value & " " & neg_rad & " "
& zheight
pshape.Exec document.helix.radius.value & " " &
document.helix.radius.value & " " & zheight Loop
//Exiting curve creation mode pshape.Exec "Select"
End Sub
</script>
2. Save the file.
More information on the Apply_click() procedure The following commands are in the macro:
LET $radius = 10 LET $pitch = 4 LET $numturn = 10
In the HTML file, we have already assigned values to the radius, pitch and the number of turns when we created their text boxes.
We assigned values to the variables neg_radius and zheight as in the macro commands.
The following commands are in the macro:
LET $neg_radius = -$radius LET $zheight = $pitch / 4
In the HTML file, we use the values from the text boxes of the radius and the pitch. So for neg_radius,
neg_rad = - document.helix.radius.value
This assigns the negative value of the radius to the variable neg_rad.
The command
document.helix.radius.value
defines the elements in the HTML file from which the string is
extracted. The code value extracts the numeric value of the string in the textbox called radius. There are two other elements,
document and helix:
document denotes the current page;
helix is the name of the form which contains the text box.
Similarly, a value is assigned to the variable zheight.
zheight = document.helix.pitch.value /4
For the following macro commands, we use the pshape.Exec method to replace some of the code.
create curve THROUGH $radius 0 0
WHILE $numturn {
LET numturn = $numturn - 1 $neg_radius $radius $zheight $neg_radius $neg_radius $zheight $radius $neg_radius $zheight $radius $radius $zheight }
Select
So, the create curve command line has become:
pshape.Exec "create curve"
The pshape.Exec method uses strings to communicate with PowerSHAPE.
$radius 0 0
has now been replaced by
pshape.Exec document.helix.radius.value & " 0 0"
The & joins the strings on either side of it.
So,
document.helix.radius.value & " 0 0"
is a single string containing the contents of the Radius text box and two zeros. This is equivalent to the macro command:
$radius 0 0
The while loop in the macro has been replaced by Do Until Loop. Both loops operate in a similar way.
The following have been replaced by the pshape.Exec command and variables containing strings.
$neg_radius $radius $zheight
$neg_radius $neg_radius $zheight
$radius $neg_radius $zheight
$radius $radius $zheight
The strings are combined using & and " " characters.
So, for example
$neg_radius $radius $zheight becomes
pshape.Exec neg_rad & " " & document.helix.radius.value & " " &
zheight
Linking the procedure to the Apply button To link the procedure to the Apply button:
1. Add onClick=Apply_click() to the input object for the Apply button as follows:
<INPUT TYPE=button value=" Apply " onClick=Apply_click() >
2. Save the file.
More information on the onClick command
In the string below, the onClick command defines the action when you click the Apply button. In this case, it calls the procedure
Apply_click(), that was added in the script.
<INPUT TYPE=button value=" Apply " onClick=Apply_click() >
Testing your application To run your application,
1. Press the right mouse button in the Browser window in PowerSHAPE to display a popup menu.
2. Select Refresh from the popup menu to install the latest helix.htm file in the browser.
3. Click the Apply button in the Browser window to create a helix using the default values.
4. Change the values in the three text boxes.
5. Click Apply again to create a helix using the new values.