Given by Wojtek Furmanski, Subhash Nair, Tom Pulikal at JSU HPC Summer Institute for Undergraduates, Jackson MS on June 15 1998. Foils prepared July 5 98
Outside Index
Summary of Material
FMS Training Space |
ASP For Web linked Databases |
NetMeeting Collaboration |
CORBA Collaboration |
JWORB |
Rational Rose |
OMBuilder |
VBA-Tutor |
WebFlow |
COM |
Visual Authoring for Jager |
TVR/DirectX |
Outside Index Summary of Material
Wojtek Furmanski, Subhash Nair and Tom Pulikal |
Northeast Parallel Architectures Center |
Syracuse University, Syracuse NY |
furm@npac.syr.edu |
presented at JSU HPC Summer Institute |
June 15, 1998, Jackson, MS |
FMS Training Space |
ASP For Web linked Databases |
NetMeeting Collaboration |
CORBA Collaboration |
JWORB |
Rational Rose |
OMBuilder |
VBA-Tutor |
WebFlow |
COM |
Visual Authoring for Jager |
TVR/DirectX |
Praveen Aravamudham |
Bruno Goveas |
Meryem Ispirli |
Sunil Samuel Jos |
Subhash Nair |
Hasan Ozdemir |
Zeynep Ozdemir |
Shrideep Pallickara |
Tom Pulikal |
Mahesh Rengaswamy |
Sachin R. Shanbhag |
Abbasaheb Yadav |
We start with a Site Tour to illustrate the content organization in the FMS Training Space |
We then illustrate Web / Access Database support for SPEEDES, CMS and other software packages |
Next, we show document editor support and we verify changes in the Access Database |
Finally, we show PowerPoint foils database with SPEEDES talks by by Jeff Steinman |
We illustrate here Active Server Pages i.e. Microsoft IIS support for dynamic generation of HTML |
VBS code, inlined as <%..%> bracket is pre-processed by the server in the server-side-include style (similar to Netscape's LiveWire) |
ASP model offer convenient support for database inserts via the ADO (Abstract Data Object) interfaces (on top of OLE-DB) |
Server side scripting environment for dynamic and interactive webpage development |
Easy to develop using VBScript or JScript |
Extensible using ActiveX server components |
Rapid application development using other Microsoft technologies like ADO, ODBC etc., |
Application Object
|
Request Object
|
Response Object
|
Server Object
|
Session Object
|
<!-- #Include file="utils.asp" --> <!--include file containing some variable declarations--> |
<!-- The file that lists the classes in the left frame // sp_classes_list.asp ---> |
<html> |
<head><title>Speedes Database - sp_classes_table Table List</title></head> |
<body bgcolor="#ffffff"> |
<% |
Dim selid, clsid |
selid = request.querystring("id") 'get the id from the querystring |
if(selid = "") then |
selid = 1 |
end if |
` open up a database connection and execute the SQL query |
Set OBJdbConnection = Server.CreateObject("ADODB.Connection") |
OBJdbConnection.Open "speedes" |
` select id and name of all classes from the classes table |
SQLQuery = "SELECT clsid,cname FROM sp_classes_table" |
`execute the SQL query and get the resultset |
Set typelist = OBJdbConnection.Execute(SQLQuery) |
%> |
<% |
if typelist.EOF then `if no records are present then print a message |
%> |
<!-- There are no records in the system --> |
<% else %> <!-- otherwise print the data --> |
<table border="0" cellspacing="2" cellpadding="2" bgcolor="<% = tabbgcol %>" |
align="center" valign="middle" width="90%"> |
<tr align="left" valign="middle"> |
<% |
Do While Not typelist.EOF ` print the data in a loop and construct the url |
clsid = typelist("clsid") ` on the fly |
sx = "<a target=main href=sp_classes_rec.asp?id=" & clsid & ">" |
` if the record is the selected one then change the |
` background color |
if(StrComp(selid,clsid,vbBinaryCompare) = 0) then |
sx = sx & "<font color=" & thfgcol & ">" & typelist("cname") & "</font></a>" |
%> |
<th align="left" valign="middle" nowrap bgcolor="<% = hgltcol %>" width="90%"> |
<% = sx %> |
<% else |
sx = sx & "<font color=" & thfgcol & ">" & typelist("cname") & "</font></a>" |
%> |
<th align="left" valign="middle" nowrap width="90%" bgcolor="<% = trbgcol %>"> |
<% = sx%> |
<% end if %> |
</th></tr> |
< tr align="left" valign="middle"> |
<% |
typelist.MoveNext ` loop through the records until it reaches EOF |
Loop |
%> |
</tr></table> |
<% |
end if 'end of outer if |
OBJdbConnection.close ` close the connection at the end |
%> |
</body> |
</html> |
<!-- #Include file="utils.asp" --> <!--include file with certain variable declarations--> |
<html><head><title>Speedes Database - sp_classes_table Record</title></head> |
<body bgcolor="#ffffff"> |
<% |
Dim id,cname,SQLQuery,listurl |
id = request.querystring("id") ` get the id of the record to display |
` open a database connection and execute the query |
Set OBJdbConnection=Server.CreateObject("ADODB.Connection") |
OBJdbConnection.Open "speedes" |
SQLQuery = "SELECT * from sp_classes_table where clsid = " & id |
Set typelist = OBJdbConnection.Execute(SQLQuery) |
if typelist.EOF then ` check if there are any records |
%><!-- There are no sp_classes_table records --> |
<% |
else |
cid = typelist("clsid") |
%> |
<! -------- Class descriptions ---Print the record information here --------> |
<table border="0" cellspacing="2" cellpadding="2" width="100%" |
bgcolor="<% = tabbgcol %>" align="center" valign="middle"> |
<tr><td align="left" valign="middle" width="100%"> |
<blockquote><b>#include </b> <%= typelist("cinclude") %> |
</blockquote> |
</td></tr> |
<% |
if (typelist("cheader").ActualSize > 0) then ` check if value is present and print |
%> |
<tr><td align="left" valign="middle" width="100%"> |
<blockquote> |
<font size="+1"><%= typelist("cheader") %></font> |
</blockquote> |
</td></tr> |
<% End if %> |
</table> |
<!--------- Print the rest of the data here .... ---> |
<!--------- End of class descriptions ----------> |
<% |
` list the class member functions by using the subroutine |
printFunction "Public" |
printFunction "Protected" |
printFunction "Private" |
printFunction "Free Standing Function" |
`list the class member variables by using a subroutine |
printData "Public" |
printData "Protected" |
printData "Private" |
end if ` end of outer if |
OBJdbConnection.close ` close connection once everything is done |
%> |
<% listurl = "sp_classes_list.asp?id="&id %> |
<!-- client side script executed in the browser --> |
<script LANGUAGE="VBScript"> |
Sub Window_OnLoad <!-- update the list frame every --> |
window.top.list.navigate("<% = listurl %>") <!-- time a class record is displayed--> |
end sub |
</script> |
<% `subroutine to print the member functions |
Sub printFunction(ByVal attrib) |
FuncQuery = "select fname from sp_functions_table where " |
FuncQuery = FuncQuery & " fattrib ='"&attrib&"' AND fclsid = " & cid |
FuncQuery = FuncQuery & " order by fname" |
Set funclist = OBJdbConnection.Execute(FuncQuery) `form the query and execute it |
if(StrComp(attrib,"Free Standing Function") = 0) then |
attrib = "Free Standing" |
end if |
attrib = attrib & " Methods" |
if(Not funclist.Eof) then ` if result set is not empty then print them |
printRecord attrib,funclist |
end if |
End Sub |
%> |
<% `print the member variables depending on the attribute |
Sub printData(ByVal attrib) |
DataQuery = "select dname from sp_data_table where " |
DataQuery = DataQuery &" dattrib ='" & attrib &"' AND dclsid = " & cid |
DataQuery = DataQuery & " order by dname" |
`form the query and execute it |
Set datalist = OBJdbConnection.Execute(DataQuery) |
attrib = attrib & " Data" |
if(Not datalist.Eof) then ` if the result set is not empty then print it |
printRecord attrib,datalist |
end if |
End Sub |
%> |
<% ` print the record set passed for the class member |
Sub printRecord(ByVal attrib, ByVal list) |
cnt = 0 |
if(Not list.Eof) then |
%> |
<center><table width="100%" border="0"> |
<tr BGCOLOR="<% = trbgcol %>"> |
<td align="left" valign="middle" nowrap width="100%"> |
<font size="2" face="Arial" color="<% = thfgcol %>"> |
<b><% = attrib %> </b></font> |
</td></tr> </table> |
<table width="80%" border="0"> |
<% |
Do While Not list.EOF |
cnt = cnt + 1 |
if( (cnt Mod 2) > 0) then ` print it in two rows |
%> |
<tr> |
<% end if %> |
<td align="left" width="80%" valign="middle"> |
<% For Each fld in list.Fields %> |
<% = fld.Value %> ` use the generic field object to display the value |
<% Next %> |
</td> |
<% |
list.MoveNext ` loop through the record list |
Loop |
%> |
</table></center> |
<% |
End if ' for record display |
End Sub |
'------------------------------------------ |
%> |
</body> |
</html> |
Microsoft's real-time collaboratory env: supports audio, video, chat, whiteboard, browser sharing |
To be used as real-time collaboratory option in the FMS Training Space |
Current demo illustrates NetMeeting in action within our other collaboratory space for telemedicine, CareWeb. |
Our base communication framework to support distributed simulation, computing and collaboration is Object Web RTI, i.e. DMSO RTI as CORBA service over JWORB |
Here we show a demo of a similar but simpler collaboratory system JDCE (Java Distributed Collaboratory Env) by Shrideep Pallickara at NPAC |
JDCE implements collaboratory as a Java CORBA service (or pure Java, using RMI = Remote Method Invocation) |
Facilities |
Object Bus over IIOP (Internet Inter-ORB Protocol) |
Services |
|
|
|
The CORBA standard tries to obviate problems resulting from boundaries such as networks, programming languages, and operating systems |
An implementation of the standard defines
|
Each implementation of the CORBA standard is able to communicate with any other implementation of the standard., the protocol used to achieve this end is the Internet Inter-ORB Protocol (IIOP). |
The IIOP specification defines a set of data formatting rules, called CDR (Common Data Representation), which is tailored to the data types supported in the CORBA Interface Definition Language (IDL) |
Using the CDR data formatting rules, the IIOP specification also defines a set of message types that support all of the ORB semantics defined in the CORBA core specification |
The messaging formats and the CDR constitute the General Inter-ORB Protocol (GIOP). |
IIOP is the GIOP message format sent over the Transmission Control Protocol/ Internet Protocol (TCP/IP).
|
CORBAservices are widely available object services that virtually all CORBA objects are most likely to use.
|
CORBAfacilities are commonly occurring object frameworks that many CORBA applications could possibly use
|
Identification Of
|
Habanero from NCSA
|
JSDT (Java Shared Data Toolkit) from Javasoft
|
Distributed Objects: Residing on the Distributed Engine provided by any of the following approaches to Distributed Processing.
|
Java Beans : The Only Component Framework for Java. |
Java with its mobile code facility handles inter-object communications within its native environment.
|
Only the Java Programming language has an inverse mapping to IDL.
|
Convergence of Object models.
|
Java's multi-threading feature facilitates the optimal framework for
|
Java-CORBA greatly simplifies software upgrades of Clients in large distributed systems.
|
The onset of ORB-lets, dynamically downloadable or browser-resident as in the case of Netscape/Visigenic ORB.
|
A distributed-approach towards Collaborative Environments. |
Support for IIOP- and RMI- based Transport Protocols.
|
A Distributed Event and Exception Heirarchy. |
Based on the CORBA Naming Service. |
The Client initiates a bind to the sessionScheduler Object.
|
It starts with the createBahn(String PartyName, String _applicationServerName) throws jdceBahnException function.
|
The Client now has the option to decide whether he wishes to join an existing Bahn (party) or initiate the existence of a new one. In the latter case Step[2] is repeated as mentioned earlier.
|
Once Steps II and III are over and done with, the Client in a Distributed Collaboration mode. |
The Client can invoke operations specified in IDL definitions for the dataBahn. These operations are preceded by public int register(String _clientName, clientProxy _clientObjRef) throws jdceBahnException, jdceClientException .
|
Once the registration process is over and done with the Client could invoke operations such as public boolean broadcastMessage(jdceMessage _message), public boolean whisperMessage(jdceMessage _message, String _clientName) throws jdceClientException, jdceBahnException etc. |
class java.lang.Object
|
class java.lang.Throwable (implements java.io.Serializable)
|
If a Client exception has occurred. The following exception types can occur:
|
If a Bahn exception has occured. The following exception types could occur.
|
module jdce { |
module util {
|
}; |
}; |
IDL Definition |
java.lang.Object
|
There are three types of client changes:
|
module java { |
module lang { extensible struct Object; |
}; |
}; |
module jdce { |
module util { |
module message { |
extensible struct jdceMessage { |
string sender; |
string applicationType; |
string messageType; |
string protocolType; |
::java::lang::Object content; |
}; |
}; |
}; |
}; |
IDL DEFINITION |
The Message Object Implementation consists of the following methods, which conform to the JavaBeans Design Patterns.
|
The jdceMessageQueue is implemented as a Linked List for faster operations of addition/removal of messages. |
The message queue provides for reporting availability of data on the queuebesides providing for returning the queue Contents as a stream of bytes or an array of Strings. |
The queue has a in-lined class the QueueEnumerator which provides an Enumeration of the QueueContents. |
The queueWidget has pointers to the preceeding Element and the elements successor.
|
class QueueWidget { |
Object object; |
QueueWidget prev; |
QueueWidget next; |
QueueWidget(Object object, |
QueueWidget queueWidget1, QueueWidget queueWidget2) { |
this.object = object; |
prev = queueWidget1; |
next = queueWidget2; |
} |
} |
Besides the operations mentioned above, the queue provides for handling priority messages expressed by the addItemToTop() method. |
For every client (RMI or CORBA) there are worker threads assigned to handle the call-backs from the server-side.
|
Both the RMIWorker and CORBAWorker Threads are scheduled by the jdceThreadScheduler. The fact that the ThreadScheduler schedules both the RMI and CORBA threads facilitates collaboration involving RMI and CORBA Clients. |
Starting the Active Object Server, the default port it binds to is 14000 % osagent |
Starting the Gatekeeper which acts as a HTTP-tunneler for Callbacks through firewalls, the default port it runs on is 15000 % gatekeeper |
Starting up the RMIregistry on some port, (ports less than 1024 require administrative priveleges) say 7000 % rmiregistry 7000 |
Starting the Naming Service, with the nameContext Root as JDCE %java -DORBservices=CosNaming -DSVCnameroot=JDCE -DJDKrenameBug com.visigenic.vbroker.services.CosNaming.ExtFactory JDCE namingLog |
Starting the main Object Server, which starts up both the RMI/CORBA sessionScheduler. %java -DORBservices=CosNaming -DSVCnameroot=JDCE jdce.impl.corba.sessionServer |
The HTML file, for the JDCE applet. |
<applet code=demos.chat.ChatUser.class width=400 height=350> |
<param name=org.omg.CORBA.ORBClass |
value=com.visigenic.vbroker.orb.ORB> |
<param name=ORBservices value=CosNaming> |
<param name=SVCnameroot value=JDCE> |
</applet> |
CORBA Binding Process. |
private void getSessionSchedulerHandle() { |
try { |
// Initialize the ORB. |
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(this, null); |
// Calculate Start time |
long startTime = System.currentTimeMillis(); |
// Bind to the Scheduler Object |
/* Get a reference to the Naming Service */ |
org.omg.CORBA.Object nameServiceObj = |
orb.resolve_initial_references("NameService"); |
if (nameServiceObj == null) { |
System.out.println("Name Service Object = null"); |
return; |
} |
org.omg.CosNaming.NamingContext nameService = |
org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj); |
if (nameService == null) { |
System.out.println("nameService = null"); |
return; |
} |
NameComponent[] collabName = |
{ new NameComponent("Collaboration", "Scheduler")}; |
_chatSession= |
jdce.scheduler.sessionSchedulerHelper.narrow(nameService.resolve(collabName)); |
} catch(Exception e) { |
System.out.println("Exception: " + e); |
} |
} |
RMI Binding Process |
private void getSessionSchedulerHandle() { |
try { |
remoteObject = |
Naming.lookup("rmi://jojo.npac.syr.edu:7000/Scheduler"); |
} catch (java.lang.Exception exec) { |
System.out.println("Unable to lookup created Scheduler"); |
} |
_chatSession = (jdce.scheduler.RMISessionScheduler) remoteObject; |
} |
public void getDataBahnHandle() { |
try { |
_chatSession.createBahn(partyName, "Chat"); |
System.out.println("New Party created"); |
} catch (jdceBahnException e) { |
System.out.println("Exception in creations" +e); |
} catch (Exception e) { |
e.printStackTrace(); |
} |
long startTime = System.currentTimeMillis(); |
try { |
// Initialize the ORB. |
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(this, null); |
/* Get a reference to the Naming Service */ |
org.omg.CORBA.Object nameServiceObj = |
orb.resolve_initial_references("NameService"); |
if (nameServiceObj == null) { |
System.out.println("Name Service Object = null"); |
return; |
} |
org.omg.CosNaming.NamingContext nameService = |
org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj); |
if (nameService == null) { |
System.out.println("nameService = null"); |
return; |
} |
NameComponent[] collabName = |
{ new NameComponent("Collaboration", partyName+"Chat"+"Coordinator")}; |
_chatBahn= |
jdce.byteways.dataBahnHelper.narrow(nameService.resolve(collabName)); |
} catch(Exception e) { |
System.out.println("Exception: " + e); |
} |
long stopTime = System.currentTimeMillis(); |
System.out.println("Avg Ping to invoke = " |
+ ((stopTime - startTime)/1000f) + " msecs"); |
} |
public void getDataBahnHandle() { |
try { |
_chatSession.createBahn(partyName, "Chat"); |
System.out.println("New Party created"); |
} catch (jdceRMIBahnException e) { |
System.out.println("Exception in creations" +e); |
} catch (Exception e) { |
e.printStackTrace(); |
} |
// long startTime = System.currentTimeMillis(); |
try { |
_chatBahn = _chatSession.getDataBahnHandle(partyName, "Chat"); |
} catch (jdceRMIBahnException e) { |
System.out.println("Exception in creations" +e); |
} catch (Exception e) { |
e.printStackTrace(); |
} |
} |
{ // Initialize the ORB. org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(thisClient); |
// Create the ClientControl object. ClientControlImpl control = new ClientControlImpl(thisClient); orb.connect(control); |
try { /* Get a reference to the Naming Service */ org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService"); |
if (nameServiceObj == null) { |
System.out.println("Name Service Object = null"); |
return; } |
org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj); |
if (nameService == null) { |
System.out.println("nameService = null"); return; } NameComponent[] collabName =new NameComponent ("Collaboration", thisClient.partyName+"Chat"+"Coordinator") |
}; System.out.println(thisClient.partyName+"Chat"+"Coordinator"); |
try { int id= thisClient._chatBahn.register(thisClient.clientName, (jdce.client.clientProxy)control); thisClient.clientID=id; System.out.println("Registration Succeeded"); } catch (jdceBahnException e) { System.out.println(e.typeToString(e.getType())); System.out.println("Registration Failed"); } catch (jdceClientException e){} |
try { |
control = new RMIClientControlImpl(thisClient); |
identity= "rmi://jojo.npac.syr.edu:7000/" + thisClient.clientName; Naming.rebind(identity, control); System.out.println("ClientControl Export done."); |
} catch (RemoteException re) { System.out.println("Exception in ClientControlImpl.main: " + re); } |
catch (MalformedURLException e) { |
System.out.println("MalformedURLException CoordinatorImpl.main: " + e); |
} |
try { int id= thisClient._chatBahn.register(thisClient.clientName, control); |
thisClient.clientID=id; |
System.out.println("Registration Succeeded"); |
} catch (jdceRMIBahnException e) { |
System.out.println(e.typeToString(e.getType())); |
System.out.println("Registration Failed"); } |
catch (jdceRMIClientException e){} |
catch (RemoteException e) { |
System.out.println("OPOOOOuch!!"); |
} |
} |
JWORB (Java Web Object Request Broker) is our multi-protocol (now HTTP + IOOP) middleware server |
Difficult to demo as middleware invisible... |
We illustrate HTTP and IIOP integration by timing a ping call over IIOP channel while invoking a Web page from JWORB - to notice a transient ping performance drop |
We now move towards demos of high level visual authoring tools |
Rose by Rational is the leading implementation of the new standard UML (Uniform Modeling Language) |
UML supports OO design for various object-oriented languages in terms of a family of diagram topologies (class, sequence, interaction, activity, deployment..) |
Microsoft has a similar product called Visual Modeller as part of Visual Studio Enterprise Edition |
Another approach for object modeling was taken by HLA OMT (Object Model Template) |
Since HLA objects are simple (no methods, only attributes), a database / tabular / spreadsheet approach sounds more practical |
OMDT tool by Aegis Corp is one such editor |
We developed OMBuilder by using VBA scripting to customize Excel spreadsheet editor |
Object Model Builder (OMBuilder) at NPAC |
VBA (Visual Basic for applications) offers powerful macro programming capabilities on top of COM based Microsoft application suite |
We are also developing VBA self-tutor tools to aid VBA scripting inside various applications |
We are now customizing other applications for their use in WebHLA, for example PowerPoint, Outlook98, Project98 etc. |
Visual Basic for Applications is essentially Visual Basic with the services of the Microsoft Office Object hierarchy exposed to it |
Everything you do in VBA involves manipulating objects, as every unit of content is an object. The entire content of the the application is encapsulated in these objects. Working with these objects and manipulating them to suit the requirements gives functionality to the application. |
Some examples of objects include Excel Worksheet, Workbooks, Word Documents and PowerPoint slides. |
The way the objects that make up the application are arranged relative to each other together with the way the content and functionality are divided among the object is called the Object Hierarchy or the Object Model. |
VBA is short for Visual Basic for Applications. It is a powerful interactive programming language which tightly integrates with the Microsoft Office. It support a BASIC-like command structure whose interpreted coding style makes it an ideal scripting tool for the Office family of applications. Also it inherently supports OLE automation. |
In the dark days of Windows application programming, the developer had to struggle with the vast array of functions called the Windows API. This had to be tightly coupled with the main procedures and the something called the `Message-Loop' which is used by windows to process events. Visual Basic changed all that by providing the developer with a simple intuitive BASIC-like syntax to program Windows applications. This concept radically changed the world of Windows programming and brought the arcane art to the mainstream. |
Microsoft soon released its Office suite of applications. The large base of Win95 users and the ever-growing popularity of the applications themselves rendered the release of customized or multi-featured versions of Office unfeasible. Consequently in order to maintain the user-base something had to be provided to allow the user to customize his working environment to his own convenience. Care had to be taken to see that any such medium would not be very complicated to use and would easily facilitate rapid development. The ease-of-use and its tight bond with the Windows environment rendered Visual Basic as the ideal medium for this purpose. |
Visual Basic was soon selected as the standard scripting language for the Office family of applications. It was then endowed with a vast array of so-called Object Libraries specific to each application in the Office Suite. The programming core remained the same. Thus was born Visual Basic for Applications |
The top-level object in the hierarchy is the Application Object. Eg. Microsoft Word is the Application object. Each object can in turn have child objects. Eg. The Workbook Object has the Worksheet object as the child. |
Every Objects has Properties and supports some Methods. Working with these objects involves manipulating these properties by using these methods. |
VBA uses a core language which is surrounded by a hierarchy of usable objects which encapsulate most of the functionality of the application. |
Objects group features into a hierarchy that is more understandable than a flat macro language consisting of a myriad of commands. |
VBA allows customizability of almost every conceivable feature of Office application using macro procedures, that can be manipulated using the user-interface of the application. |
Exposure to the entire suite of Microsoft Office Objects : Each Office application exposes its functionality as a set of programmable objects. VBA makes it possible to access these objects and manipulate them to suit the need of the application. |
Consistent syntax across applications : VBA makes it possible to use BASIC-like code syntax across the entire suite of Office applications eliminating the need to learn a new language to use a different application. |
Ability to use Active-X Controls: VBA supports the use of a powerful new software development medium called Active-X Control. These are reusable software components which are pre-built to function as individual modules carrying out a specific task. They are like manufactured spare parts ready to be plugged into the cars on the assembly-line. |
A powerful development environment: The integrated development environment of VBA is available with most of the major Office Applications. It sports a consistent look and feel throughout removing the need for retraining and speeding up application development. |
- VBA programs can call other VBA programs even if they exist in another application |
A powerful development environment: The integrated development environment of VBA is available with most of the major Office Applications. It sports a consistent look and feel throughout removing the need for retraining and speeding up application development. |
- VBA programs can call other VBA programs even if they exist in another application |
- An expression is a group of items that yield a value which can be a number, string, Boolean or even an object |
- Expressions can be made of any combination of functions, operators, variables and constants. |
Some examples of expressions are |
2+2 -- Returns a numeric value |
me AND you -- returns a Boolean value |
ActiveSheet -- Returns the currently active sheet object in Excel |
Now -- Returns today's date |
|
In Expressions, elements are glued together with the help of operators. |
Some operators include : |
Numerical -- +, -, /, * ^ |
String -- & Concatenates two strings |
Numerical and String comparisons -- =, <>, >=, >, <, <= |
Logical -- Not, And, Or, Xor. |
Object Comparison -- Is Checks to see |
if the two objects are the same. |
Besides the basic operators VBA provides many built-in functions for playing with numbers and strings and objects. |
These functions make life easier for the programmer and remove the necessity for writing his own functions for performing basic operations. |
Some operations which can be performed are summarized below. |
Abs -- Returns the absolute value of a no. |
Exp -- Returns the exponent of a no. |
Log -- Returns the natural logarithm of a no. |
Sgn -- Returns the sign of a no. |
Sqr -- Returns the square root of a no. |
Rnd -- Returns a random no. between 0 and 1 |
Cbool -- Convert a value to a Boolean value |
Cdate -- Converts a value to a date value |
CStr -- Converts a value to a string data type |
Int -- Removes the fractional part of a real no. |
Sin -- Returns the sine of an angle expressed in radians |
Cos -- Returns the cosine of a no, expressed in radians |
Atn -- Returns the arc tangent of an angle in radians |
Instr -- Finds a substring in a longer string |
Strcomp -- Compares two strings |
Asc -- Converts a single character to its ASCII value, |
Chr -- Converts a no. to a character with its ASCII value. |
Val -- Converts a string to a numeric value |
Lcase -- Converts a string to its lower case, |
Ucase -- Converts a string to its upper case. |
Lset -- Left Justifies a string |
Rset -- Right- Justifies a string |
Mid -- Returns a no. of characters from any position . |
Trim -- Removes blanks from the left & right sides of a string. |
Space -- Creates a string containing blank spaces. |
String -- Creates a string containig repeated characters. |
Some invisible string charters used in programming are. |
TAB -- Chr (9) |
LF (linefeed) -- Chr (10) |
CR (carriage return) -- Chr (13) |
Common String Characters |
Objects in Visual Basic are similar to objects in the real-world |
They are arranged in some kind of hierarchy in the object library of the application. |
Objects have properties as well as methods which in effect define the objects interface and its existence. |
Properties set or return information about the state of the object such as the width of a column of cells in Excel or the background of a PowerPoint slide. |
Methods perform some action on an object such as printing a Word Document |
Properties can appear on either side of an equal sign. The can be set (left-hand side) or their value can be used (right-hand side) |
Method can only be used on the right-hand side when their return value is being used. |
Methods may or may not return a value |
The syntax of using properties is
|
The syntax of using methods is |
Variable = Object.method [(arguments)] |
Eg. Set currcell = Selection.Offset(1,1) |
Objects may provide a default property. When the object is being used without the property being specified by name, it is assumed by default. |
An object can be specifically qualified by mentioning its entire hierarchy tree. |
Eg Application.Documents(3). |
VBA uses the active object when an object isn't qualified. |
The With ... .End with statement lets you use the properties and methods of a specific object in a single block. |
The Set statement can be used to create an object variable to refer to a specific object. |
The Microsoft Excel Object Library provides a rich array of objects which can be used to manipulate the application right down to the cell value. |
The top-level object (Application) controls the Excel Application, the files it loads and the windows it displays.
|
Worksheet items describe the elements in a Microsoft Excel Worksheet. Eg. Range, chart |
Charting objects include object used to create and modify charts. Eg. Data series, legends |
Menu and Toolbar objects lets you access Microsoft Excel built-in menus and toolbars. They also allow you to create and manipulate your own custom menus and toolbars |
Dialog box objects lets you create, display and manipulate your own or Excel's built-in dialog boxes and even make them respond to user events like a right mouse click. |
Objects can also be contained in a collection. This characteristic is used when we are wish to manipulate objects in a group. Eg. The Workbooks collection of the Workbook object in Excel. |
Visual Basic for Applications allows us to customize the menu system of the application dynamically by using the Menu object and the Menus Collection object. |
The Menubar object and its associated collection Menubars allows us to manipulate a specific menubar in the worksheet. Each new menu is contained in its parent menubar. Hence creating a menu involves adding it to a menubar. |
Different kinds of menus are the regular menus and the shortcut menus |
The menuitem object of the menu object allows us to manipulate each item in the menu. The menuitems are what give functionality to the menu |
Each new menuitem is contained in its parent menu. Hence creating a new menuitem involves adding it to a specific menu. |
Some methods / Properties of the Menu object which will be used frequently are : |
Add -- Adds a menu to its parent object i.e.. Menubar |
Delete -- Deletes a menu from a menubar. |
Enabled -- Enables a specific menu. |
Caption -- Sets the caption of the menu |
Some methods / Properties of the Menu object which will be used frequently are : |
Add - Adds a submenu to its parent menu |
Delete - Deletes a submenu from a menu |
Caption - Sets the caption of a menuitem, |
Delete - Deletes the menuitem from the menu |
Enabled - Enables/ Disables the menuitem |
OnAction - Attaches to the item a subprocedure to be executed if the menuitem is selected |
StatusBar - Sets or returns the text in the Status Bar when mouse moves over item |
- A menu can be changed to a shortcut menu ( one which is displayed with a right mouse click ) during its creation. This is done by assigning the position parameter of the Add method to msoBarPopup. This is a predefined constant. Likewise there are many other constants defined which allow us to determine the position of the menu or menubar in the Excel Workbook |
Events are triggered by action such as mouse-clicks or key-presses. |
Actions such as selecting a cell in Excel also trigger events. |
Several objects respond to a predefined set of events. |
When we want an object to respond to an event in a particular way we write a Visual Basic event procedure. |
Some events which are recognized in Excel are. |
Activate -- Occurs when a Worksheet or WorkBook is activated |
BeforeDoubleClick -- Occurs when the user double-clicks the worksheet |
BeforeRightClick -- Occurs when the user right-clicks the worksheet. |
SheetActivate -- Occurs when the user activates a sheet on the workbook. |
WorkBookOpen -- Occurs when the user opens a workbook |
NewWorkbook -- Occurs when the user opens a new workbook |
WindowResize -- Occurs when the user resizes a window. |
Event procedures are named as follows. |
Sub Objectname_Event() |
I.e.. If a right-click event is to be detected by a sheet then use the following |
Sub Worksheet_BeforeRightClick()
|
VBA allows us to create our own forms and dialog boxes. This capability can be utilized to accept user input in the application. |
Forms consist of various controls arranged in some order. Controls are objects which are capable of accepting user inputs and detecting events. Examples of controls include : |
Button, Label, text-field and list-box. |
These controls and the form itself need to be assigned some properties. This can be done using the property sheet displayed in the designer. Default properties are already assigned to the objects. These can be changed by clicking in the sheet and typing in the required value. |
To reference folders in the Folder list |
To create, open and send custom items |
To hide or show a form page |
To change properties of a control on a page |
To modify Outlook events |
To automate Office document from outlook |
Available for each form |
Used to add procedures to forms
|
Microsoft Outlook |
VBScript code for opening Access db file |
Shows VBScript to open Access database from Outlook |
Shows Access form that was opened from Outlook |
Shows an Excel worksheet that was opened from Outlook |
Shows Word document that was opened from Outlook |
Project98-Gantt Chart View |
Pert Chart view |
Gantt Tracking View |
Resource Allocation View |
Resource Name and Resource Sheet View |
Using VBA to adjust dates |
Using VBA to open Access Database |
Using VBA to open Excel spreadsheet |
Used in Macros
|
We present first a few typical WebFlow demos for image processing |
Next, we show how to write a WebFlow module in Java |
It's easy: each Java class can become a module after it implements webflow.Module interface with methods: init, run, destroy. |
|
|
|
|
|
|
|
Every module written for webflow, the class must implement the interface Module. |
public class My_module implements Module { .... } |
The Module interface is defined in package webflow.backend |
public interface Module { |
public MetaModule initialize(); |
public void run(); |
public void stop(); |
public void destroy(); |
} |
Example: This is an example of a module spawns an applet at the user side to input a text file and passes the file name to the next module which gets the image. |
public MetaModule initialize() { mm = new MetaModule("Input Module "); //create an MetaModule instance |
sp = new OutputPort(); // port for transmitting data to another module |
mm.putPortID(sp.getPortID()); // registering a port which the module uses InetAddress local = java.net.InetAddress.getLocalHost(); //gets the host on //which the module reside hostName = local.getHostName(); //gets the host name of which the module //resides listener = new ServerSocket(0); //creates a new server socket for the module portNumber = listener.getLocalPort(); //port number on which the socket is //listening |
contd.. |
// Html Code to Display Applet |
String htmlString=new String(htmlFile); |
/* String(htmlFile) must include the following This would allow the applet at the client side to interact with the module, by opening a socket connection since you pass the hostname and port number to the applet as parameters |
CODE = "webflow.modules.demo.atest.InAp.class" //where //the applet resides WIDTH=300 HEIGHT=300 //dimensions PARAM Name=Host VALUE= hostName; PARAM NAME = portnum VALUE String.valueOf(portNumber); */ mm.setHTML(htmlString); //stores the html file in the //MetaModule object return(mm); //returns the MetaModule object } |
public class OutputPort extends Port implements Serializable { public void send(Object str) { os= new ObjectOutputStream(getSocket().getOutputStream()); os.writeObject(str); } } |
public class InputPort extends Port implements Serializable { public Object receive() { is= new ObjectInputStream(getSocket().getInputStream()); str = (String) is.readObject(); return(str); } } |
Hence in the initialize method the statement |
sp = new OutputPort() creates a new OutputPort object, the super class does the registering with the Connection Manager |
mm.putPortID(sp.getPortID()) registering a port which the module uses it |
public void run() { |
filenamesocket = listener.accept(); //creates a socket connection ois = new ObjectInputStream(filenamesocket.getInputStream()); // to receive the input form the user fileName = (String) ois.readObject(); sp.send(fileName); //transmits the user input to the next module |
} |
public void stop(): |
This method stops the execution of the module. |
public void destroy() { aSocket.close(); //closes socket connection with applet sp.destroyPort(); //closes socket connection with the other //module } |
Register the module in the module.txt file |
eg: |
module's name - webflow.modules.myTest.myModule |
module representation class - webflow.frontend.WebNodeWBClient |
host - myhost.edu |
port number -8888 |
then you would have an entry in the modules.txt file as follows |
webflow.modules.myTest.myModule myhost.edu8888 webflow.frontend.WebNodeWBClient |
Jager is DMSO HLA application distributed together with the RTI release |
It is a simple multi-player video game with minimal 2D interface and keyboard control |
We integrated it with WebFlow and OMBuilder as a proof-of-concept visual authoring kit for HLA |
User can specify game topology using Webflow and parameters using OMBuilder |
|
TVR is a joint project with IBM Watson on exploring scalable VRML/Java3D based multi-user collaboratory environments (worlds) |
Previous demo used JSDA collab server and represented users as simple VRML avatars (cones) |
New demo uses CORBA collaboratory server |
We are also including avatar/humanoid animation |
|
|
We show first a few DirectX games that come with the release: Clowns, Duel, Paper Planes. |
Next, we show a minimal Hello, World demo and we walk you though the source code to point out all essential elements |
Similar to HLA/RTI but |
without object/database model |
(OMT, OML, FOMs, SOMs) |
Direct X / Play Multiplayer Gaming Samples |
Create the DirectDraw object |
Decide the application behavior |
Change the display mode |
Create flipping surfaces |
Render to the surfaces |
Flip the surfaces |
Release and destroy the DirectDraw objects |
Enumerate the service providers |
Create the DirectPlay object |
Create or join a session
|
Create a player |
Send/Receive messages |
///////////////////////////////////////////////////////////////////// |
// Helloworld.cpp : Implementation source file for the helloworld // |
// application using DirectDraw & DirectPlay // |
// // |
// Application : Demo application for DirectX/DirectPlay for JSU // |
// summer institute // |
// // |
// Platform : Intel Pentium 166 MHz, WindowsNT 4.0, Visual C++ 5.0// |
// // |
// Author : Subhash Nair (subhash@cat.syr.edu) // |
///////////////////////////////////////////////////////////////////// |
#define WIN32_LEAN_AND_MEAN // For faster builds & smaller executables |
#include <windows.h> // Our standard Windows header |
#include <ddraw.h> // Header for DirectDraw |
#include <dplay.h> // Header for DirectPlay |
//Global Constants |
const char *msg = "Hello World!"; //Our famous message, courtesy Kernighan & Ritchie!! |
const int window_width = 640; // These 3 values for window width, window height and |
const int window_height = 480; // and bits per pixel correspond to a standard display |
const int bits_per_pixel = 8; // mode on most monitors |
const DWORD UpdateDelay = 0; // How often our screen will be updated |
const char sessionName[32] = "Welcome"; //Our session name |
//Our session's Globally unique identifier |
const GUID sessionGUID = { 0x6db0f1d1, 0xff0c, 0x11d1, |
{ 0x9a, 0x17, 0x0, 0x0, 0xc0, 0x23, 0xca, 0xf3 } }; |
//The message structure we are going to send and receive |
typedef struct _MESSAGE |
{ |
int x; |
int y; |
}MESSAGE; |
Global constants |
Declaration |
static HINSTANCE hinst; // The instance handle of our application |
static RECT wndRect; // A rectangle object for the window's client area |
static HWND hwndApp; // The handle of the application window |
static LPDIRECTDRAW lpdd; // Pointer to DirectDraw object |
static LPDIRECTDRAWSURFACE lpFrontBuffer; // Pointer to front buffer |
static LPDIRECTDRAWSURFACE lpBackBuffer; // Pointer to back buffer |
static LPGUID lpServiceProviderGuid; // Pointer to GUID of the service provider |
static LPDIRECTPLAY lpDirectPlay1; // Pointer for the DirectPlay Object |
static DPID playerID; // To store the player ID |
static BOOL joinSession; // Join a session(TRUE) or create a new one(FALSE) |
// Function declarations for forward references |
static BOOL WinInit( HINSTANCE hInst, int nCmdShow ); //Initialize & set up Windows |
static BOOL DXInit(void); //Initialize & set up DirectX components |
static void UpdateFrame(char* direction); |
static void CleanUp(); |
// Called by DirectX when enumerating service providers |
static BOOL FAR PASCAL DirectPlayEnumerateCallback( |
LPGUID lpSPGuid, |
LPTSTR lpszSPName, |
DWORD dwMajorVersion, |
DWORD dwMinorVersion, |
LPVOID lpContext |
); |
// Called by DirectPlay when enumerating sessions |
static BOOL FAR PASCAL EnumSessionsCallback( |
LPDPSESSIONDESC lpSessionDesc, |
LPVOID lpContext, |
LPDWORD lpdwTimeOut, |
DWORD dwFlags |
); |
//Helper functions |
static HRESULT CreateDirectPlayInterface(); |
static HRESULT FindSession(); |
static HRESULT OpenSession(); |
static HRESULT MakePlayer(); |
Variable & |
Function |
Declarations |
//Entry point for the windows program |
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) |
{ |
MSG msg; |
joinSession = FALSE; //By default create new session |
if(strcmp(lpCmdLine,"join")==0) |
joinSession=TRUE; |
if( !WinInit( hInstance, nCmdShow ) ) // Initialize & set up Windows |
return FALSE; |
if( !DXInit() ) // Initialize & set up DirectX |
return FALSE; |
ShowCursor(FALSE); //Hide the mouse pointer |
// Start windows loop |
while( 1 ) |
{ |
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) |
{ |
if( !GetMessage( &msg, NULL, 0, 0 ) ) |
return msg.wParam; |
TranslateMessage(&msg); |
DispatchMessage(&msg); |
} |
else |
{ |
UpdateFrame("NONE"); //Update the screen |
} |
} |
} |
The main Function - WinMain() |
A command line argument |
`join' must be supplied |
to join an already existing |
session |
We update the screen even when |
no keys are pressed because the |
other player might have changed |
position. |
// WindowProc --- Handles messages for the main application window |
static long FAR PASCAL WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) |
{ |
PAINTSTRUCT ps; |
HDC hdc; |
static BOOL fFirstPaint = TRUE; |
switch( message ) |
{ |
case WM_KEYDOWN: //Check for key presses |
switch( wParam ) |
{ |
case VK_UP: |
UpdateFrame("UP"); |
break; |
case VK_DOWN: |
UpdateFrame("DOWN"); |
break; |
case VK_LEFT: |
UpdateFrame("LEFT"); |
break; |
case VK_RIGHT: |
UpdateFrame("RIGHT"); |
break; |
case VK_ESCAPE: |
case VK_F12: |
PostMessage(hWnd, WM_CLOSE, 0, 0); |
return 0; |
} |
break; |
case WM_PAINT: |
hdc = BeginPaint( hWnd, &ps ); |
EndPaint( hWnd, &ps ); |
return 1; |
case WM_DESTROY: |
// We're done, clean up |
CleanUp(); |
break; |
} |
return DefWindowProc(hWnd, message, wParam, lParam); |
} |
The message processing function - WindowProc() |
// WinInit --- Make window class and create window |
static BOOL WinInit( HANDLE hInstance, int nCmdShow ) |
{ |
WNDCLASS wc; |
BOOL rc; |
// Save instance handle for later use |
hinst = hInstance; |
wc.style = CS_DBLCLKS; |
wc.lpfnWndProc = WindowProc; |
wc.cbClsExtra = 0; |
wc.cbWndExtra = 0; |
wc.hInstance = hInstance; |
wc.hIcon = NULL; |
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); |
wc.hbrBackground = GetStockObject(BLACK_BRUSH); |
wc.lpszMenuName = NULL; |
wc.lpszClassName = "HelloWorldClass"; |
rc = RegisterClass( &wc ); |
if( !rc ) |
return FALSE; |
// Create window |
hwndApp = CreateWindowEx( |
WS_EX_APPWINDOW, |
"HelloWorldClass", |
"Hello World", |
WS_POPUP | WS_VISIBLE, |
0, |
0, |
640, |
480, |
NULL, |
NULL, |
hInstance, |
NULL ); |
if( hwndApp == NULL ) |
return FALSE; |
UpdateWindow( hwndApp ); |
return TRUE; |
} |
WinInit() |
Initializes and sets up the |
windows part of our application |
//Initialize DirectX components |
static BOOL DXInit() |
{ |
HRESULT hr; |
DDSURFACEDESC ddsd; // Structures needed for Surfaces |
DDSCAPS ddscaps; |
//-----------Set up Direct Play------------------ |
// Get the service provider you want to use |
DirectPlayEnumerate(DirectPlayEnumerateCallback, hwndApp); |
// Create the DirectPlay object |
CreateDirectPlayInterface(); |
// If you want to join a session, find it |
if(joinSession) |
FindSession(); |
// Join/Create a session |
OpenSession(); |
// Create a player |
MakePlayer(); |
DXInit(): |
Initializes & sets up the DirectX |
part of our application |
Setting up |
DirectPlay |
Continued... |
//----------Set up DirectDraw--------------------- |
// Create the DirectDraw object |
hr = DirectDrawCreate( NULL, &lpdd, NULL ); |
if( hr != DD_OK ) |
return FALSE; |
// Decide the application's behaviour |
hr = lpdd->SetCooperativeLevel( hwndApp, DDSCL_EXCLUSIVE | |
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX ); |
if( hr != DD_OK ) |
return FALSE; |
// Set the display mode |
hr = lpdd->SetDisplayMode( window_width, window_height, bits_per_pixel ); |
if( hr != DD_OK ) |
return FALSE; |
ddsd.dwSize = sizeof( ddsd ); |
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; |
ddsd.dwBackBufferCount = 1; //We are using one back buffer |
//Specify surface capabilities |
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
hr = lpdd->CreateSurface( &ddsd, &lpFrontBuffer, NULL ); |
if( hr != DD_OK ) |
return FALSE; |
// get pointer to back buffer |
ddscaps.dwCaps = DDSCAPS_BACKBUFFER; |
hr = lpFrontBuffer->GetAttachedSurface(&ddscaps, &lpBackBuffer ); |
if( hr != DD_OK ) |
return FALSE; |
/* Initial screen layout & rendering can be done here if needed */ |
return TRUE; |
} |
Setting up |
DirectDraw |
640 X 480 X 8 |
// Update the screen with new coordinates |
static void UpdateFrame(char* direction) |
{ |
HRESULT hr; |
HDC hdc; |
LPDPID lpmsgFrom = new DPID; //ID of player sending the message |
LPDPID lpmsgTo = new DPID; //ID of player who will receive the message |
MESSAGE *pMessage = new MESSAGE; |
DWORD msgSize = 8; |
static SIZE size; //To store text size |
static int xchange = 1; //Change along x direction |
static int ychange = 1; //Change along y direction |
//My initial coordinates |
static int x = window_width/2; |
static int y = window_height/2; |
//The other player's initial coordinate |
static int x1 = window_width/2; |
static int y1 = window_height/2; |
//-------- To introduce delay in updating screen----------- |
static DWORD lastTickCount = 0; |
DWORD thisTickCount; |
thisTickCount = GetTickCount(); |
if((thisTickCount - lastTickCount) <= UpdateDelay) |
return; |
lastTickCount = thisTickCount; |
//---------------------------------------------------------- |
UpdateFrame(): |
Redraws the objects at |
their new position |
Since we have used an |
update delay of 0, this |
doesn't take effect. |
If we had used, say, 5ms, |
this function wouldn't |
continue execution until |
5ms had elapsed |
Continued... |
//Check if any messages were received from the other player |
hr = lpDirectPlay1->Receive(lpmsgFrom, lpmsgTo, DPRECEIVE_ALL, pMessage, &msgSize); |
if(SUCCEEDED(hr)) //If yes, ... |
{ |
// Update his coordinates |
x1 = pMessage->x; |
y1 = pMessage->y; |
} |
//Erase the back buffer to remove 'Hello World!' from previous position |
DDBLTFX ddbltfx; |
ddbltfx.dwSize = sizeof( ddbltfx ); |
ddbltfx.dwFillColor = PALETTEINDEX(0); |
hr = lpBackBuffer->Blt( NULL, |
NULL, |
NULL, |
DDBLT_COLORFILL | DDBLT_WAIT, |
&ddbltfx); |
if(lpBackBuffer->GetDC(&hdc) == DD_OK) |
{ |
GetTextExtentPoint32(hdc, msg, strlen(msg), &size ); |
//Update my coordinates |
if(strcmp(direction,"UP")==0) //If UP arrow was pressed |
if(yɬ) y-=ychange; |
if(strcmp(direction,"DOWN")==0) //If DOWN arrow was pressed |
if((y+size.cy) < window_height) y+=ychange; |
if(strcmp(direction,"LEFT")==0) //If LEFT arrow was pressed |
if(xɬ) x-=xchange; |
if(strcmp(direction,"RIGHT")==0) //If RIGHT arrow was pressed |
if((x+size.cx) < window_width) x+=xchange; |
Continued... |
Fills the back buffer |
with the color specified |
in ddbltfx.dwFillColor |
SetBkColor( hdc, PALETTEINDEX(0) ); |
//Draw the other player at his new position |
SetTextColor( hdc, RGB(255, 255, 255) ); |
TextOut(hdc,x1,y1,msg, strlen(msg)); |
//Draw myself at my new position |
SetTextColor( hdc, RGB(196, 0, 38) ); |
TextOut(hdc,x,y,msg, strlen(msg)); |
//Send my new position to the other player |
pMessage->x = x; |
pMessage->y = y; |
hr = lpDirectPlay1->Send(playerID, 0, DPSEND_GUARANTEE, pMessage, 8); |
lpBackBuffer->ReleaseDC(hdc); |
lpFrontBuffer->Flip(NULL,DDFLIP_WAIT); //Flip buffers |
} |
delete lpmsgFrom; |
delete lpmsgTo; |
delete pMessage; |
} |
Here, we draw at the |
new positions |
// Callback function for enumerating service providers |
static BOOL FAR PASCAL DirectPlayEnumerateCallback( |
LPGUID lpSPGuid, |
LPTSTR lpszSPName, |
DWORD dwMajorVersion, |
DWORD dwMinorVersion, |
LPVOID lpContext |
) |
{ |
//Look for the TCP/IP service provider for DirectPlay |
if (strstr( lpszSPName, "TCP") != NULL) |
{ |
// Make space for the service provider's GUID. |
lpServiceProviderGuid = new GUID; |
if (lpServiceProviderGuid == NULL) //If memory could not be allocated |
::MessageBox(NULL,"Could not allocate memory for service provider's GUID", |
"HelloWorld", MB_OK); |
else |
*lpServiceProviderGuid = *lpSPGuid; // Store the GUID of the service provider |
return(FALSE); //Returning false stops further enumeration |
//Since we found our service provider, we return false |
} |
return(TRUE); //Continue enumeration |
} |
DirectPlayEnumerateCallback(): |
DirectPlay calls this function for each |
service provider it detects on the machine |
// Helper function - Creates the DirectPlay object |
static HRESULT CreateDirectPlayInterface() |
{ |
HRESULT hr; |
// Retrieve a DirectPlay 1.0 interface. |
hr = DirectPlayCreate(lpServiceProviderGuid, &lpDirectPlay1, NULL); |
if FAILED(hr) |
{ |
if (lpDirectPlay1) |
lpDirectPlay1->Release(); |
::MessageBox(NULL,"DirectPlayCreate Failed", "HelloWorld", MB_OK); |
} |
delete lpServiceProviderGuid; |
return (hr); |
} |
CreateDirectPlayInterface(): |
Actually creates the DirectPlay object |
Once we create the DirectPlay |
object, we no longer need the |
service providers GUID |
//Look for a Hello World Session which might be already running |
static HRESULT FindSession() |
{ |
HRESULT hr; |
DPSESSIONDESC sessionDesc; |
ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC)); |
sessionDesc.dwSize = sizeof(DPSESSIONDESC); |
sessionDesc.guidSession = sessionGUID; |
hr = lpDirectPlay1->EnumSessions(&sessionDesc, 1000, EnumSessionsCallback, |
hwndApp, DPENUMSESSIONS_AVAILABLE); |
if FAILED(hr) |
::MessageBox(NULL,"Could not find any HelloWorld sessions", "HelloWorld", MB_OK); |
return(hr); |
} |
// Callback function for enumerating sessions |
static BOOL FAR PASCAL EnumSessionsCallback( |
LPDPSESSIONDESC lpSessionDesc, |
LPVOID lpContext, |
LPDWORD lpdwTimeOut, |
DWORD dwFlags |
) |
{ |
if (dwFlags & DPESC_TIMEDOUT) |
::MessageBox(NULL,"Could not find a HelloWorld session!....Timed Out", "HelloWorld", MB_OK); |
else |
::MessageBox(NULL,"Found a HelloWorld session!", "HelloWorld", MB_OK); |
return(FALSE); |
} |
FindSession(): |
Enumerates other DirectPlay |
sessions with same GUID |
EnumSessionsCallback() |
is called by DirectPlay for each session it finds. |
// Helper function - Creates/Joins a session |
static HRESULT OpenSession() |
{ |
HRESULT hr; |
DPSESSIONDESC sessionDesc; |
ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC)); |
if(joinSession) //To join a session |
sessionDesc.dwFlags = DPOPEN_OPENSESSION; |
else |
{ |
// To host a new session. |
sessionDesc.dwFlags = DPOPEN_CREATESESSION; |
strcpy(sessionDesc.szSessionName, sessionName); |
sessionDesc.dwMaxPlayers = 10; |
} |
sessionDesc.dwSize = sizeof(DPSESSIONDESC); |
sessionDesc.guidSession = sessionGUID; |
sessionDesc.dwSession = 2; |
hr = lpDirectPlay1->Open(&sessionDesc); |
if(FAILED(hr)) |
::MessageBox(NULL,"Open Failed", "HelloWorld", MB_OK); |
return(hr); |
} |
OpenSession(): |
Creates or joins a session |
// Helper function - Creates a player |
static HRESULT MakePlayer() |
{ |
HRESULT hr; |
// Create a player |
hr = lpDirectPlay1->CreatePlayer(&playerID, "Billy", "Bill Clinton", NULL); |
if(FAILED(hr)) |
::MessageBox(NULL,"CreatePlayer Failed", "HelloWorld", MB_OK); |
return(hr); |
} |
// Clean up before exiting |
static void CleanUp() |
{ |
//Done with DirectDraw |
if( lpFrontBuffer ) |
{ |
lpFrontBuffer->Release(); |
lpFrontBuffer = NULL; |
} |
lpdd->RestoreDisplayMode(); |
lpdd->Release(); |
//Done with DirectPlay |
if (lpDirectPlay1) |
{ |
lpDirectPlay1->DestroyPlayer(playerID); |
lpDirectPlay1->Close(); |
lpDirectPlay1->Release(); |
} |
PostQuitMessage( 0 ); |
} |
MakePlayer():Creates a new player |
CleanUp(): Releases DirectX objects & buffers |
Topics for Discussion : |
What XML is all about |
Drawbacks Associated with HTML |
Use of XML |
Origin of XML |
A Sample XML Document |
Applications of XML |
The Extensible Style-up Language (XSL) |
XML is a mark-up language written to augment text in HTML, thus capturing as many as information from SGML, the parent mark-up language. |
XML allows you to define your own tags, and manipulate with them. |
XML files need a DTD to define the tags that you want to use, in release 1.0 |
The tags can be defined in the same file, through use of Schema. |
The XML as well as the DTD files are then parsed in the XML Parser. |
An XSL File is also needed to define the characteristics of the text to be used in the XML file to be displayed on the Web. |
The XML File as well as the XSL File are then parsed in the XSL Parser to generate a HTML file that is then displayed on the Web. |
XML developed Web-Pages can be viewed only in Internet Explorer 4.04. |
HTML gives no information regarding the meta-data that make up the data to be displayed on the web. |
HTML does not represent the data as the way as it needs to be manipulated online on the web. It merely provides a rich way of documents ont he web. |
HTML is a flat-tag language that has it's own set of tags defined, giving the user very little choice of manipulating one's own tags for simplification. |
Data when downloaded from the web sometimes contain SGML like mark-up codes that are totally unusable. |
XML provides the ability to augment HTML text with XML tags to make smarter Web pages and Intranets. |
XML is all about metadata and is aimed at the information of the data itself that can be decode, manipulated, and displayed on the web. |
XML is all about sets and subsets. |
XML shall be straightforwardly usable over the Internet. |
XML has been designed for ease of implementation and operability with SGML and HTML. |
XML Documents shall be easy to create and will be able to support a large variety of applications. |
Developed by the XML Working group under the auspices of the WORLD WIDE WEB CONSORTIUM (W3C) in 1996. |
List of Parsers available for Parsing :- |
Microsoft's MSXML Parser, release 1.8 |
NXP, An XML Parser written in Java by Robert Mukila |
DATACHANNEL'S Channel Manager written for parsing XML Documents in Java |
LARK, A non-validating XML Processor written in Java by Tim Bray, version-0.91 |
Tcl/XML, an XML Parser written in Tcl. |
Alfred, A non-validating XML Parser in Java from Microstar, version=1.2 |
Larval, XML Parser in Java from Steve Ball |
XML Documents can be created by two ways |
An external file, namely a DTD (Document Type Definition) is created for initializing the tags to be used inside the XML Document. |
The tags to be used in the XML file can be declared inside the XML Document itself at the beginning by use of a <s:/schema> tag. |
<?XML VERSION="1.0"?> |
<DOCTYPE library SYSTEM "video.dtd> |
<library> |
<name>Block-Buster Video</name> |
<films> |
<film censored="yes" year=1998"> |
Titanic</film> |
<film censored="no" year="1974"> |
Titanic</film> |
</films> |
</library> |
<!ELEMENT library (name,films,film) |
<!ELEMENT name (#PCDATA)> |
<!ELEMENT films (#PCDATA)> |
<!ELEMENT film (#PCDATA)> |
where (#PCDATA) denotes that the tags that are to be used are Characters tags only. |
<?XML VERSION="1.0"?> |
<s:schema id="Video Schema"> |
<element Type id="name"> |
<string/> |
</element> |
<element type id="film"> |
<string/> </element> |
<element Type id="films"> |
<element Type ="#film" occurs="ONEORMORE"> |
</element> |
<element Type id="library"> |
<element Type = "#name"> |
<element Type = "#films"> |
</s:schema><!-- start of the use of tags> |
Chemical Mark-up Language |
http://www.venus.co.uk/omf/cml/intro.html |
Channel Definition Format |
http://www.w3c.org/TR/NOTE-CDFsubmit.html |
Resource Description Format |
http:www.w3c.org/RDF/ |
Web-Broker, a distributed object processing system which makes use of XML for scripting purposes. |
http://www.w3.org/Submission/1998/07/ |
The Open Software Description Format |
http://www.w3c.org/TR/NOTE-OSD.html |
MathML, A mathematics modelling language written with use of XML |
XSL - The Extensible Style-up Language is needed to convert the XML file to a HTML file. |
More Information about XSL can be found at |
http://www.microsoft.com/xml/xsl/tutorial/tutorial.asp |