Navigation  without Java Scripts

About the Web Equation Solver

Introduction

The Web Equation Solver (WES) is a tool that makes it possible to build numerical calculation models based on numerical equations. The WES is task independent and depends only on the possibility of representing the task as a set of numerical equations.

The magic facility of the WES is the possibility of making multidirectional calculations depend upon a set of known (preset) and unknown (void) data. Here the 'data' term means the set of variables used in the equations. By using the preset data and a set of numerical equations, the WES calculates the unknown data if possible.

If the model is represented by the following equation:

Cost=Price*Amount,

there are tree possible ways to use it:

1) Cost=Price*Amount, if Price and Amount are known and Cost is void

2) Price=Cost/Amount, if Cost and Amount are known and Price is void

3) Amount=Cost/Price, if Cost and Price are known and Amount is void

The WES considers a known variable if its value is numerical (INTEGER or REAL). On the other hand the WES considers an unknown variable if its value is an empty string. The result of the calculation is REAL.

So, if the user sends a set of data like:

Amount = 10,

Cost = 1200,

Price = "",

to the WES, then WES will use way No 2 (Price=Cost/Amount) to find the following result:

Amount = 10,

Cost = 1200,

Price=120.

The model described above is a very simple model represented by only one equation. A real model can have a set of numerical equations and even conditions for when to use which of them.

The Web Solver works via the Internet or the Intranet communication using the CGI Protocol.

No other software is needed on the client's computer, except for usual Internet communication tools like MS Internet Explorer, Netscape Navigator etc.

The User Interface and the Calculation Model for comunicating with the WES can be programmed by writing the appropriate .HTM files.

Programming the Web Solver

To program the WES,  it is necessary to prepare two pages in html format:

The Start page for the task, which is used as the initial page.
The Template page, which is used by the WES for sending the results of the calculations to the user and for receiving new data.

Usually the Template page and the Start page are almost identical. The only difference is that in the Template page you should use some special symbols and definitions. When the WES solves the equation set, it replaces some symbols and sends the modified page to the user. Then the user makes new data inputs, and the process continues in the same way. Thus the data exchange between the user and the Web Solver is based on html pages that are dynamically created at each step.

First we should consider the structure and coding of the Template page, as it is the main page used in the communication process.

The template page must contain some necessary special data:

Equations
The name of the template page
Input fields
Message output field
Resulting data coloring scripts

Equations

The equations must be entered in the Template page in the following form (here we use the equation explained above):

<INPUT TYPE="HIDDEN" NAME="slvRULE" VALUE="Price*Amount+(-1)*Cost">

where:

"slvRule" is the predefined name

"Price*Amount+(-1)*Cost" is the equation.

You can see that the form of the equation differs from the form discussed before. That is because the current version of the Web Solver only permits the use of first order linear equations and only understands the operations plus (+) and multiply (*). If you need the subscription operation, it should be used as the multiplication by (-1). Furthermore, the equations must be in a form where the left (or right) part of the equation is 0. Then you do not need to use this part of the equation.

Thus the equation explained before in the form of:

Cost=Price*Amount

is the same as:

Price*Amount-Cost=0

and the Web Solver will understand it as:

Price*Amount+(-1)*Cost

If the model has more than one equation, then the equations must be separated by a comma and a new line, e.g.:

<INPUT TYPE="HIDDEN" NAME="slvRULE"

VALUE="Price*Amount+(-1)*Cost,

Amount1+Amount2+(-1)*Amount ">

which means that the variable Amount can be found as the sum of   "Amount1" and "Amount2".

The Name of the Template

From the name of the template page, the Web Solver gets the name of the file to be used as the template at the next step.

It should be entered in the following form:

<INPUT TYPE="HIDDEN" NAME="slvTEMPL" VALUE=" EXAMPLE.TPL">

where

"slvTEMPL" is the predefined name and

"EXAMPLE.TPL" is the name of the HTML page used as the template.

Input Fields

The input fields makes it possible to enter source data to the Solver and to get the Solver's solutions.

Each input field must be used in this form:

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Cost" VALUE="$vCost$">

where:

MAXLENGTH may have any convenient value,

NAME="Cost" - defines the name of the Variable also used in the equation (here we use names from the described example),

VALUE="$vCost$" shows the place where the output data will be entered by the Web Solver. The Dollar chars are used as marked brackets, and the 'v' char shows that the string $vCost$ should be replaced by the value of the Variable "Cost" when this is found.

Thus for the above example, we should have this set of input field definitions:

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Price" VALUE="$vPrice$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Cost" VALUE="$vCost$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount" VALUE="$vAmount$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount1" VALUE="$vAmount1$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount2" VALUE="$vAmount2$">

The input field can be placed at any needed position in the HTML page, e.g. in a table cell.

Message Output Field

The purpose of the message output field is to send messages from the Web Solver to the end user.

The Web Solver can inform the end user about successfully resolved equations or about invalid data and maybe invalid sets of data.

The message output field must be defined in a form like:

<TEXTAREA ROWS="3" COLS="60" NAME="slvMSG">$mMsg$</TEXTAREA>

Where:

ROWS and COLS may have any reasonable value,

"slvMSG" is the predefined name,

$mMsg$ is the predefined string which will be substituted by the Web Solver's message to the end user.

Resolved Data Marking Scripts

During the communication with the end user, the Web Solver provides the end user with information on different situations.

The main message will be sent to the Message Output field. The Web Solver can also mark some variables. It is the programmer that chooses how to mark a variable. The programmeronly has to place the special data in the template in a form like:

$c<VariableName>$ where VariableName is the name of the variable used in the equation.

The user may define the script that will replace this special data depending on the event, in the form of:

<INPUT TYPE="HIDDEN" NAME="EventName" VALUE="Any String, defined by Programmer">

where "EventName" is one of the predefined event names.

There is a set of predefined event names, which can be used:

Wrong Input Data Events:

usrOnInvalidData - If the user enters an invalid number.

usrOnSrcConflict - If the source data and the equations conflict.

This needs to be described in detail:

If we have an equation like:

Cost=Price*Amount

and the user enters numbers for all variables, e.g.:

Cost=100,

Price=15,

Amount=1000,

there is a conflict between the source data and the equation - 15*1000 does not equal 100.

The Web Solver checks this situation before calculating and informs the user if such a conflict has occured.

The Web Solver also marks the conflicting variables using substitution at $c<VariableName>$ for each variable.

usrOnResConflict

The same situation may occur without a conflict between the source data and the equations, but with a conflict between the resolved data on one hand and the entered data and the equations on the other hand. The Web Solver checks this kind of situation after the calculation has been made. It can also mark the variables of the conflict.

Resolution Results:

usrOnPreset - The value of the variable was preset by the user.

usrOnVoid - The value of the variable in the user's input is void.

usrOnNotSolved - The value of the variable in the user's input is void and was not resolved.

usrOnSolved - The Web Solver resolved the value of the variable with any result.

usrOnNegative - The Web Solver resolved the value of the variable. The result is Negative.

usrOnZero - The Web Solver resolved the value of the variable. The result is Zero.

 

Here is an example of the substitution script definitions. Here we only color the results, but any other information in the HTML format could be colored as well.

<INPUT TYPE="HIDDEN" NAME="usrOnInvalidData" VALUE="BGCOLOR=#0080ff">

<INPUT TYPE="HIDDEN" NAME="usrOnSrcConflict" VALUE="BGCOLOR=#008000">

<INPUT TYPE="HIDDEN" NAME="usrOnResConflict" VALUE="BGCOLOR=#ffff00">

<INPUT TYPE="HIDDEN" NAME="usrOnPreset" VALUE="">

<INPUT TYPE="HIDDEN" NAME="usrOnVoid" VALUE="">

<INPUT TYPE="HIDDEN" NAME="usrOnSolved" VALUE="BGCOLOR=#00ffff">

<INPUT TYPE="HIDDEN" NAME="usrOnNotSolved" VALUE="BGCOLOR=#00800f">

If the results do not have to be marked, the script can be an empty string. Neither is it necessary to use marking rules.