![]() |
GETTING STARTED |
VScript like HTML is composed of tags. A tag may or may not represent
a visible element on the screen. The Tag has the following format.
<tag [identifier], [attributes]>tagbody</tag>
ex:-
<button help,pos="100,100,300,200",text=Help>
</button>
For some tags tag name has to be followed by an identifer name that
identifies the tag element.
Each tag supports a certain set of attributes.
Understands a certain set of messages.
Generates a certain number of events.
Provides certain number of data values.
ATTRIBUTES
Some tags must have an identifer and may support one or more attributes.
The attributes have the form
attributename=value and are seperated by comma. Attributes can be used
to configure components resulting from tags.
ex:-
<button help,pos="100,100,300,200",text=Help>
</button>
MESSAGES
Each tag can understand a certain set of messages. Tag elements respond
appropriately to different messages it recieves. Messages have the following
format.
identifier.messageName(arg1,arg2...),
Multiple messages are seperated by comma.
EVENTS
Each tag supports a certain set of events. Each event is generated
in responce to some activity. Events can be handled by placing event tag
inside the tag body. The event tag body can contain a comma seperated list
of messages that will be sent when the event occures.
ex:-
<button help,pos="100,100,300,200",text=Help>
<event click>
help.settext(help clicked),
</event>
</button>
Here when the help button is clicked the text on the button is changed
to 'help clicked'.
DATA VALUES
Each tag component can provide a set of data values. Values provided
by the various tag components can be obtained and placed as arguments to
messages.
Data values can be obtained using the following format.
#tagidentifier.get(datavalue)#
ex:-
<button help,pos="100,100,300,200",text=Help>
<event click>
vsr.print(#help.get(data)#)
</event>
</button>
This will result in printing of buttons text, ie 'Help' when button
is clicked on the standard output.
When ever some message is to be sent to the interpreter the identifier
vsr is used.
ex:- vsr.print(hello world),
MY FIRST SCRIPT PROGRAM
The first tag in the script is normally the document tag. It can hold
all other tags and has attributes that set look and feel for the whole
script document. The event generated by components are handled by using
the event tag. Try to run the following script present in file first.txt.
<document doc1,bcolor="202,50,50",border=2>
<form form1,pos="100,100,900,900",bcolor="140,20,20">
<event formshow>
vsr.print(formshow1),
</event>
<button
b1,text=Show Form2,pos="100,100,300,200">
<event
click>
form2.show(),
vsr.print(showing form2),
</event>,
</button>
</form>
<form form2,pos="100,100,900,900",bcolor="180,40,40">
<event formshow>
vsr.print(formshow2),
</event>
<button b1,text=Show Form1,pos="100,200,300,300">
<event click>
form1.show(),
vsr.print(showing form1),
</event>,
</button>
</form>
</document>
The above program creates a document containing two forms each containing
a button. When button in form1 is clicked form 2 is displayed and 'showing
form2' is written on to the standard output. When button in form2
is clicked form 1 is displayed and 'showing form2' is written on to the
standard output.
If the attribute has multiple values the values have to be put within
quotes as in bcolor="180,40,40".
POSITIONING COMPONENTS
Positioning of the components is done using the pos attributes. The
format is pos="left,top,right,bottom".
In order to specify to coordinages always assume that the screen size
is always 1000 X 1000. Then specify the coordinates as if they are to be
placed in a 1000 X 1000 pixel screen.
ex:- pos="100,100,900,950".
VSR KEYWORD
When ever any message is to be sent to the interpreter, like to output
some thing to standard output the vsr keyword can be used.
ex:-
vsr.print(hello world),
This is all you need to get started with VScript, a lot can be learned just by looking at sample programs.