First we will see the OOP part. We have a class Converter which make two objects, Metric and US. Because each one need some literals, strings and numeric, we use two stack objects, which each hold a series of data. Using the symbol ! before a stack object we place the items of stack object, not the object to the calling stack. The items from stack objects just moved to the new stack, so d1 and d2 would have zero length just at the call to class constructor, for each one. We will see a Part 2 which we can use it
Part I
|
|
Let
d1=Stack,
d2=Stack
|
Copy this code after part1 to a module Conv1
|
|
Inches=Metric.Convert(75,"Centimeters",
US("Inches")) |
The idea is to make a lambda function every time we decide the names of units from one object to other. The converter object return another object (look the value member), which need the name of the unit as a parameter. So US("Miles") returtn an object, but not a converter object. This object also has a value and need a parameter too. Because we want to read another value, we use a group and not a lambda function. Final the ConvertFunc() function return a lambda function which combine the factors to make a fast multiplication (without using objects).
The last part, the Converter.
Now copy the part one and the code below to a new module say Conv2. Now we place a user interface, and we can insert in two text boxes values, and we can change from dropboxes the units for each system. Also a thread show the time (and refresh the status bar).
Function Local2() is an updated function from info big file (info.gsb), which included in M2000 setup. This used to validate the input string. Validation done without the decimal point. This attatched after this stage. The validation for decimal point happen before the call to Local2() on the ValidString event for each TextBox. A Call Local calls a function as a sub, so we place the same name space (here the Conv2 module is the current name space).
Use Locale 1033 for engilsh or Locale 1032 for greek as first statement. This control the decimal point character, so 1032 set "," (use Monitor statement in M2000 console, to see the state of M2000 Environment).
|
|
def
SkipValidation1=True,
SkipValidation2=True |
George Karras
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.