METHOD AT PROGRAMMING AND A MECHANISM FOR HANDLING HTML-DOCUMENT
The present invention relates to a programming method, and particularly to a method of programming in JavaScript functions for carrying out a given task, particularly for facilitating the definition of new elements. The invention also relates to a mechanism for handling the contents of an html document .
Self-defined or autodefined elements can be created in Microsoft Explorer, Version 5, and in later versions, by employing a given syntax, the use of which is, unfortunately, complicated. Firstly, it is necessary to declare a so-called name- space which is placed in the root element <HTML> . For example, <HTML xmlns:x> implies that all self-defined elements shall have the prefix "x". The thus created script is placed in an HTC-file, a text file with the file ending HTC, which gives the script a style-class via a series of attach com- ands through the syntax "Θmedia all", whereafter the element is coupled together with the function if said "class" is given to the element, for example <element class="function">. This gives rise to several HTC files and at least one CSS- file, these files being unable to co-act.
Consequently, an object of the present invention is to provide a novel method relating to the programming of functions for pages that can be read by a web reader, said method making it easier to create functions that can be interpreted by the web reader.
The object of the invention is achieved with a method which comprises creating a novel mechanism which formats one page beforehand and marks with a temporary ID, each element on the
page provided with a namespace-prefix, wherein the mechanism calls a function that has the same name as the element and transmits with the given ID. This achieves synchronisation of function and element.
A further object of the invention is to provide such a mechanism that is able to handle the contents of an html document effectively.
As a result of the aforesaid mechanism, the function called is aware of the ID of the element and initiates a process that reads in the data contained by the element, processes this data and writes to the element, all in a space of time shorter than a millisecond, and then releases the element. The mechanism then passes to the next element and calls its function, wherewith the same sequence of events is repeated. When the mechanism has gone through all of the elements on said page and the page is recreated, the first function is again summoned and again locks on the element, wherewith the process continues from where it was earlier. The entire process is much quicker than can be discerned by the eye and everything is therewith discerned as a whole.
The mechanism significantly simplifies the methodology of coupling functions to self-defined, or auto-defined elements. It suffices with a namespace declaration and the linked mechanism for the functions on the page to be able to co-act, because the values they read-in are public, i.e. available to all other functions. This also enables local script, written by the user himself, to integrate with functions defined by the mechanism. The mechanism is such as to enable it to be extended.
The mechanism causes all summoned functions to be converted to a coherent group of functions, i.e. a program. Such a program will consist of functions associated with self- defined html elements and activate only those elements that are found. This means that the program will have different appearances, depending on which elements are found in the document or on said page. If an element lies inwardly of another, i.e. is nestled, the functions belonging to the elements will also be nestled in each other, therewith influ- encing the result. This enables programs to be created in roughly the same way as if pieces of LEGO® have been placed together, by adding elements to the document and/or by nestling these elements together. This implies a totally novel script methodology and a completely novel type of the reuse of program codes.
Only element attributes, i.e. so-called element variables, can be used in coding the mechanism, meaning that variables cannot be used at all. In order for the mechanism to func- tion, it is assumed that all ongoing processes can be interrupted and again read-in from the element at any time whatsoever.
In order to save temporarily certain ongoing operations, there are used named, but empty, elements and their attributes instead of using global variables. Data tags is another name for such elements.
All mechanisms are supported with the aid of elements that can be called by the introduction of element ID or by rearranging their attributes. For example, an element can be made inactive or reactivated, by switching one of its attributes on or off.
The functions include coupling attributes, i.e. attributes that are also recognised by other functions. This means that the next-laid element can ask the "father element" or the "child element" what values it has and adapt itself accordingly. In turn, this means that functions not only nestle where their elements nestle, but that they also take the context into account and, in reality, together form a new function.
If links are used to call functions, it must be possible to switch off the link from one of the functions called by the mechanism, or, alternatively, to switch its goal to another goal. This methodology is normally referred to as "smartlinks" .
Creation of the inventive mechanism results in a mechanism that can organise several complicated script functions into a coherent unit, a program, by activating the script functions from an html document. The mechanism can also nestle the functions if their associated elements are also nestled.
When the mechanism is activated, it thus reads through an html document, or a page, and identifies the list of func- tions that shall be included. The mechanism then pre-formats the page for those functions that shall be included and then call these functions in sequence. This page is then updated by virtue of the mechanism constantly "flashing" the page, in the same way as a television (TV) updates the picture 32 times per second.
Multithread programming is actually an impossibility in a web reader and does not exist. True multithread means that sev-
eral calculations are execute in parallel in the processor, which is a technical impossibility from a web reader. However, the inventive mechanism allows some sort of multithread execution, by virtue of the fact that several functions can be executed in parallel and call their attendant functions individually without affecting the other "threads". They can stop and start individually without affecting the other functions. It is thus a multithread technique in principle, but not in a conventional sense, i.e. as seen from the processor.
The inventive mechanism is adapted to stop completely, if it receives an error message. However, the mechanism is not stopped directly by the error, but as a result of a conscious act. The element that caused the error is then erased and the mechanism restarted. The worst that can happen in this respect is that a function is never initiated, although the remaining functions are executed nevertheless. With this type of error it is otherwise normal for the entire script to be blocked because the functions self-lock since it cannot iso- late and break with the element causing the error, meaning that the error is constantly repeated. In practice, this normally means that it also reads all other scripts on the page. In respect of the inventive mechanism, it makes no difference whether it is the element or the function that is in error. The one activates the other. When this function is erased, the defect function is no longer actuated and, on the contrary, when the defect element is erased, the function is not required to handle the element that initiated the error. In the event of both the element and the function being de- fective, the relationship is, nevertheless, broken by the erasure. When the mechanism is restarted, after a millisecond or so, the conflict is eliminated and executed of the script continued.