SlideShare una empresa de Scribd logo
1 de 63
Descargar para leer sin conexión
VBScript
Session 11




Dani Vainstein   1
What we learn last session?

   VBScript      string manipulation.
   VBScript      string math.
   VBScript      date manipulation.
   VBScript      Formatting Strings.




Dani Vainstein                          2
Subjects for session 11

   The OOP model.
   Objects.
   COM objects.
   Set statement.
   Nothing keyword
   CreateObject function.
   New keyword.
   FileSystem object.

Dani Vainstein              3
OOP Model

   Abstractions
   Encapsulation
   Polymorphism
   Inheritance
   Reusabillity




Dani Vainstein     4
OOP Model
Abstractions

   The ability for a program to ignore some aspects of the
   information it's manipulating, i.e. the ability to focus on the
   essential.
   An abstract class cannot be instantiated.
   An abstract class may contain abstract methods and accessors.
   An abstract class can be partially implemented, or not at all
   implemented.
   Abstract classes are useful when creating components because
   they allow you specify an invariant level of functionality in some
   methods, but leave the implementation of other methods until a
   specific implementation of that class is needed.




Dani Vainstein                                                          5
OOP Model
Encapsulation

   The ability for the program to hide
   information about the implementation of a
   module from its users, i.e. the ability to
   prevent users from breaking the invariants
   of the program.
   The term encapsulation refer to
   Information hiding in software.



Dani Vainstein                                  6
OOP Model
Polymorphism

   Polymorphism is the ability for classes to
   provide different implementations of
   methods that are called by the same
   name.
   Polymorphism allows a method of a class
   to be called without regard to what
   specific implementation it provides.



Dani Vainstein                                  7
OOP Model
Polymorphism

• You might have a class named Road which calls the Drive
  method of an additional class.
• This Car class may be SportsCar, or SmallCar, but both
  would provide the Drive method.
• Though the implementation of the Drive method would
  be different between the classes, the Road class would
  still be able to call it, and it would provide results that
  would be usable and interpretable by the Road class.




Dani Vainstein                                              8
OOP Model
Inheritance

   Defining classes as extensions of existing
   classes.
   In computer science, the term
   inheritance may be applied to a variety
   of situations in which certain
   characteristics are passed on from one
   context to another.
   The term originates with the
   biological concept of a parent passing on
   certain traits to a child

Dani Vainstein                                  9
Dimensions                             Area
                                Flanks            Shape

                                                                       Perimeter



  Radious                                                 Height
  *pi             Circle                                            Rectangle
                                  angles                  Width
                                             Triangle




Where is the
right place for
                       Volume
this action?                                                depth
                                             3D

Dani Vainstein                                                                     10
OOP Model
Reusabillity

   reusability is the likelihood a segment of structured code can be
   used again to add new functionalities with slight or no
   modification.
   Reusable code reduces implementation time, increases the
   likelihood that prior testing and use has eliminated bugs and
   localizes code modifications when a change in implementation is
   required.
   Subroutines or functions are the simplest form of reuse.
   A chunk of code is regularly organized using module or
   namespace.
   Proponents claim that objects and software components offer a
   more advanced form of reusability.




Dani Vainstein                                                         11
Object Model

   Object.
   Collection.
   Container object.
   Method.
   Event.
   Property.
   Attribute.


Dani Vainstein         12
Object Model
Objects

   In computer science , an object is a data structure (incorporating
   data and methods) whose instance is unique and separate from
   other objects, although it can "communicate" with other objects.
   In some occasions, some object can be conceived of as a sub
   program which can communicate with others by receiving or giving
   instructions based on its, or the other's, data or methods. Data can
   consist of numbers, literal strings , variables, and references.
   the object lifetime (or life cycle) of an object in OOP is the
   time between an object's creation (also known as instantiation or
   construction) till the object is no longer used, and is destructed
   or freed.




Dani Vainstein                                                       13
Object Model
Collection

   An object that contains zero or more objects
   (member).
   Collections normally contain objects of the same
   class.
   Also referred to as a collection object or an
   object collection.
   Collection has normally two single read-only
   properties, Item and Count
   you usually use the Item property or method
   and pass the name or index number of the
   member.

Dani Vainstein                                    14
Object Model
Container Object

   An object that contains other objects
   from different classes.
   Collection can have properties and/or
   methods.




Dani Vainstein                             15
Object Model
Methods

   Method is a function or subroutine that is associated
   with a class in OPP.
   Like a function in procedural languages, it may contain
   a set of program statements that perform an action,
   and (in most computer languages ) can take a set of
   input arguments and can return some kind of result.
   The purpose of a method is to provide a mechanism
   for changing or accessing information stored in an
   object of the class.




Dani Vainstein                                           16
Object Model
Methods

   A method should preserve invariants associated with
   the class, and should be able to assume that every
   invariant is valid on entry to the method
   A method can have parameters.
   method may produce output, which are constrained by
   postconditions of the method.
   If the arguments to a method do not satisfy their
   preconditions, a method can raise an exception




Dani Vainstein                                       17
Object Model
Event

   In the context of programming, the occurrence
   of some particular action or the occurrence of a
   change of state that can be handled by an
   application or COM object that is invoked in
   response to the triggering of an event. .
   For example, the arrival of a message to the
   SMTP service is an event that can be handled by
   any number of Applications or objects.




Dani Vainstein                                    18
Object Model
Property

   Properties are like smart fields.
   A property is an information that is associated with an
   object.
   Each property has a value. value is a keyword in the
   syntax for the property definition.
   The variable value is assigned to the property in the
   calling code.
   The type of value must be the same as the declared
   type of the property to which it is assigned.
   properties fall into two categories: run-time properties
   and persistent properties.



Dani Vainstein                                                19
Object Model
Attribute

   Each property has attributes.
   Attributes provide information about the property.
   For example, the First Name property has the following
   attributes: Name, Display Name, Description, and Type.
   Attributes include information such as the data type of
   the profile property (for example, number, text, decimal,
   or site term), and whether the property is single-valued
   (for example, only one First Name entry is allowed per
   user) or multi-valued.




Dani Vainstein                                             20
COM
Component Object Model

   An architecture for defining interfaces (a set of abstract
   methods and properties that encompass some common
   purpose) and interaction among objects implemented by
   widely varying software applications.
   All COM interfaces are extend and derived from the
   IUnknown, interface which includes the methods
   QueryInterface, AddRef, and Release.
   COM interfaces additionally define a binary signature that
   acts as a contract between the interface designer and client
   applications written to use the interface COM classes
   provide concrete implementations of COM interfaces.




Dani Vainstein                                                21
COM
IUnknown

   The fundamental COM interface, which must be
   extended by every valid COM interface.
   IUnknown exposes three methods:
       QueryInterface, used to find out if the object
       supports a certain interface and return the interface if
       it does.
       AddRef, to increment the interface reference count.
       Release, to decrement the interface reference count.




Dani Vainstein                                                22
COM
COM Class

   An implementation of one or more COM
   interfaces.
   COM objects are instances of COM
   classes.




Dani Vainstein                            23
COM
COM Interface

   A pointer to a vtable pointer where the
   first three methods in that table are
   QueryInterface, AddRef, and Release.




Dani Vainstein                           24
COM Objects
COM Extensions Technologies

   COM+(Component Services )
   ActiveX, OLE
   SOM, DSOM – IBM’s System object model
   DCOM (Distributed COM)
       Distributed COM
   CORBA – Common Object Request Broker
   Architecture
   RMI, JavaBeans – SUN Microsystems
   technologies.
   RPC – Remote Procedure Call.

Dani Vainstein                             25
COM objects
Where they are?

   In the registry under HKEY_CLASSES_ROOT you
   will se all the classes registered in your system.
   You can find there the Scripting.FileSystemObject
   Key, Excel.Application key etc
   All those classes can be used in VBScript.
   Each class has a description, a CLSID entry and
   some a version entry.
   In CLSID you will find the class identifier.
   If you move to HKEY_CLASSES_ROOTCLSID you
   will see wich dll’s using this class.
   For more information search for <registration>
   Element topic in VBScript documentation.


Dani Vainstein                                      26
Set statement
   Assigns an object reference to a variable or property, or associates a procedure
   reference with an event.
   To be valid, object must be an object type consistent with the object being
   assigned to it.
   The Dim, Private, Public, or ReDim statements only declare a variable that
   refers to an object.
   No actual object is referred to until you use the Set statement to assign a
   specific object.
   Generally, when you use Set to assign an object reference to a variable, no
   copy of the object is created for that variable.
   Instead, a reference to the object is created.
   More than one object variable can refer to the same object.
   Because these variables are references to (rather than copies of) the object, any
   change in the object is reflected in all variables that refer to it.




Dani Vainstein                                                                    27
Nothing Keyword
   The Nothing keyword in VBScript is used to disassociate an object
   variable from any actual object.
   Use the Set statement to assign Nothing to an object variable. For
   example:
       Set MyObject = Nothing
   Several object variables can refer to the same actual object.
   When Nothing is assigned to an object variable, that variable no
   longer refers to any actual object.
   When several object variables refer to the same object, memory and
   system resources associated with the object to which the variables
   refer are released only after all of them have been set to Nothing,
   either explicitly using Set, or implicitly after the last object variable set
   to Nothing goes out of scope.




Dani Vainstein                                                                28
CreateObject Function
   CreateObject(servername.typename [, location])

   Creates and returns a reference to an Automation object.
      servername - Required. The name of the application providing
      the object.
      typename - Required. The type or class of the object to create.
      location - Optional. The name of the network server where the
      object is to be created.
   Automation servers provide at least one type of object.
   For example, a word-processing application may provide an
   application object, a document object, and a toolbar object.




Dani Vainstein                                                      29
CreateObject Function

   For example, a word-processing
   application may provide an application
   object, a document object, and a toolbar
   object.
   To create an Automation object, assign the
   object returned by CreateObject to an
   object variable:
       Dim ExcelSheet
       Set ExcelSheet = CreateObject("Excel.Sheet")




Dani Vainstein                                        30
CreateObject Function
   Once an object is created, refer to it in code using the object variable you
   defined.
   you can access properties and methods of the new object using the object
   variable.
   Creating an object on a remote server can only be accomplished when
   Internet security is turned off.
   You can create an object on a remote networked computer by passing
   the name of the computer to the servername argument of
   CreateObject.
   That name is the same as the machine name portion of a share name.
   For a network share named "myserverpublic", the servername is
   "myserver". In addition, you can specify servername using DNS format
   or an IP address.




Dani Vainstein                                                                31
CreateObject Function
Summary

   Creating an object
         Set myDoc = CreateObject (“Word.Document”)
   Using The object
         MyDoc.content = “abc”
         MyDoc.SaveAs “Doc1.doc”
         MyDoc.Close
   Free the object
         Set Mydoc = Nothing

                                    Type      COM
                                    Library   Class




Dani Vainstein                                        32
FileSystemObject Object
Basics

   When writing scripts it's often important to add,
   move, change, create, or delete folders and
   files.
   It may also be necessary to get information
   about and manipulate drives attached to the
   machine.
   Scripting allows you to process drives, folders,
   and files using the FileSystemObject (FSO)
   object model.


Dani Vainstein                                     33
New Keyword
   Keyword used to create a new instance of a class.
   If objectvar contained a reference to an object, that
   reference is released when the new one is assigned.
   The New keyword can only be used to create an instance
   of a class.
   Using the New keyword allows you to concurrently
   create an instance of a class and assign it to an object
   reference variable.
   The variable to which the instance of the class is being
   assigned must already have been declared with the Dim
   (or equivalent) statement.




Dani Vainstein                                           34
FileSystemObejct Object
Model
   The FileSystemObject (FSO) object model allows you to use the
   familiar object.method syntax with a rich set of properties, methods,
   and events to process folders and files.
   The FSO object model gives to the QTP the ability to create, alter,
   move, and delete folders, or to detect if particular folders exist, and if
   so, where. You can also find out information about folders, such as
   their names, the date they were created or last modified, and so forth.
   The FSO object model also makes it easy to process files. When
   processing files, the primary goal is to store data in a space- and
   resource-efficient, easy-to-access format.
   You need to be able to create files, insert and change the data, and
   output (read) the data.




Dani Vainstein                                                             35
FileSystemObejct Object
Model

   The FSO object model, which is contained in the
   Scripting type library (Scrrun.dll), supports text
   file creation and manipulation through the
   TextStream object.
   Although it does not yet support the creation or
   manipulation of binary files, future support of
   binary files is planned.




Dani Vainstein                                      36
FileSystemObject Objects
Main

   Main object.
   Contains methods and properties that allow you to create,
   delete, gain information about, and generally manipulate
   drives, folders, and files.
   Many of the methods associated with this object duplicate
   those in other FSO objects; they are provided for
   convenience.




Dani Vainstein                                                 37
FileSystemObject Objects
Drive Object

   Contains methods and properties that allow you to gather
   information about a drive attached to the system, such as
   its share name and how much room is available.
   Note that a "drive" isn't necessarily a hard disk, but can be
   a CD-ROM drive, a RAM disk, and so forth. A drive doesn't
   need to be physically attached to the system; it can be also
   be logically connected through a network.




Dani Vainstein                                                 38
FileSystemObject Objects
Drive Collection

   Provides a list of the drives attached to
   the system, either physically or logically.
   The Drives collection includes all drives,
   regardless of type.
   Removable-media drives need not have
   media inserted for them to appear in this
   collection.



Dani Vainstein                               39
FileSystemObject Objects
File Object

   Contains methods and properties that
   allow you to create, delete, or move a
   file.
   Also allows you to query the system for a
   file name, path, and various other
   properties.




Dani Vainstein                             40
FileSystemObject Objects
Files Collection

   Provides a list of all files contained within
   a folder.




Dani Vainstein                                 41
FileSystemObject Objects
Folder Object

   Contains methods and properties that
   allow you to create, delete, or move
   folders.
   Also allows you to query the system for
   folder names, paths, and various other
   properties.




Dani Vainstein                               42
FileSystemObject Objects
Folders Collection

   Provides a list of all the folders within a
   Folder.




Dani Vainstein                                   43
FileSystemObject Objects
TextStream Object

   Allows you to read and write text files.




Dani Vainstein                                44
Programming the
FileSystemObject

   Use the CreateObject method to create
   a FileSystemObject object.
   Use the appropriate method on the newly
   created object.
   Access the object's properties.
   Set objFSO = CreateObject("Scripting.FileSystemObject")

   Scripting is the name of the type library
   and FileSystemObject is the name of
   the object that you want to create.

Dani Vainstein                                               45
Accessing Existing Drives, Files,
and Folders

   To gain access to an existing drive, file, or folder, use the appropriate
   "get" method of the FileSystemObject object:
       GetDrive
       GetFolder
       GetFile
   Do not use the "get" methods for newly created objects, since the
   "create" functions already return a handle to that object.
   For example, if you create a new folder using the CreateFolder
   method, don't use the GetFolder method to access its properties,
   such as Name, Path, Size, and so forth.
   Just set a variable to the CreateFolder function to gain a handle to
   the newly created folder, then access its properties, methods, and
   events.




Dani Vainstein                                                                 46
Accessing the Object's
Properties

   Once you have a handle to an object, you can
   access its properties.
   For example, to get the name of a particular
   folder, first create an instance of the object,
   then get a handle to it with the appropriate
   method (in this case, the GetFolder method,
   since the folder already exists).




Dani Vainstein                                       47
Working with Drives and
Folders

   With the FileSystemObject (FSO)
   object model, you can work with drives
   and folders programmatically just as you
   can in the Windows Explorer
   interactively.
   You can copy and move folders, get
   information about drives and folders, and
   so forth.


Dani Vainstein                             48
Getting Information About
Drives

   The Drive object allows you to gain
   information about the various drives
   attached to a system, either physically or
   over a network.




Dani Vainstein                              49
Getting Information About
Drives
   The total size of the drive in bytes (TotalSize property).
   How much space is available on the drive in bytes (AvailableSpace or
   FreeSpace properties).
   What letter is assigned to the drive (DriveLetter property).
   What type of drive it is, such as removable, fixed, network, CD-ROM, or RAM
   disk (DriveType property).
   The drive's serial number (SerialNumber property).
   The type of file system the drive uses, such as FAT, FAT32, NTFS, and so forth
   (FileSystem property).
   Whether a drive is available for use (IsReady property)
   The name of the share and/or volume (ShareName and VolumeName
   properties)
   The path or root folder of the drive (Path and RootFolder properties)




Dani Vainstein                                                                      50
Working With Folders
   Create a folder - FileSystemObject.CreateFolder
   Delete a folder - Folder.Delete or FileSystemObject.DeleteFolder
   Move a folder - Folder.Move or FileSystemObject.MoveFolder
   Copy a folder - Folder.Copy or FileSystemObject.CopyFolder
   Retrieve the name of a folder - Folder.Name
   Find out if a folder exists on a drive - FileSystemObject.FolderExists
   Get an instance of an existing Folder object - FileSystemObject.GetFolder
   Find out the name of a folder's parent folder -
   FileSystemObject.GetParentFolderName
   Find out the path of system folders - FileSystemObject.GetSpecialFolder




Dani Vainstein                                                             51
Working With Files

                 There are two major categories of
                 file manipulation
                   Creating, adding, or removing data,
                   and reading files.
                   Moving, copying, and deleting files.




Dani Vainstein                                            52
Creating Files

                 There are three ways to create an empty
                 text file.
                 The first way is to use the
                 CreateTextFile method.
                 The second way to create a text file is to
                 use the OpenTextFile method of the
                 FileSystemObject object with the
                 ForWriting flag set.
                 A third way to create a text file is to use
                 the OpenAsTextStream method with
                 the ForWriting flag set.

Dani Vainstein                                                 53
Adding Data to the File
                 Once the text file is created, add data to the file using the following
                 three steps:
                 Open the text file.
                 Write the data.
                 Close the file.
                 To open an existing file, use either the OpenTextFile method of the
                 FileSystemObject object or the OpenAsTextStream method of the
                 File object.
                 To write data to the open text file, use the Write, WriteLine, or
                 WriteBlankLines methods of the TextStream object according to
                 your task.
                 To close an open file, use the Close method of the TextStream
                 object.
                 Note The newline character contains a character or characters to
                 advance the cursor to the beginning of the next line. Be aware that
                 the end of some strings may already have such nonprinting
                 characters.


Dani Vainstein                                                                         54
Reading Files

                 To read data from a text file, use the
                 Read, ReadLine, or ReadAll method of
                 the TextStream object.
                 If you use the Read or ReadLine method
                 and want to skip to a particular portion of
                 data, use the Skip or SkipLine method.
                 The resulting text of the read methods is
                 stored in a string which can be displayed
                 in a control, parsed by string functions
                 (such as Left, Right, and Mid),
                 concatenated, and so forth.

Dani Vainstein                                             55
Moving, Copying, and Deleting
Files

                 The FSO object model has two
                 methods each for moving, copying,
                 and deleting files
                   Move a file - File.Move or
                   FileSystemObject.MoveFile
                   Copy a file - File.Copy or
                   FileSystemObject.CopyFile
                   Delete a file - File.Delete or
                   FileSystemObject.DeleteFile


Dani Vainstein                                       56
Lab 11.1

   Tip
       Const     DRV_UNKNOWN = 0
       Const     DRV_REMOVABLE = 1
       Const     DRV_FIXED = 2
       Const     DRV_NETWORK = 3
       Const     DRV_CDROM = 4
       Const     DRV_RAMDISK = 5




Dani Vainstein                       57
Lab 11.2
   Declare the follow constants :
       Constants returned by Drive.DriveType
            Const   conDriveTypeRemovable = 1
            Const   conDriveTypeFixed = 2
            Const   conDriveTypeNetwork = 3
            Const   conDriveTypeCDROM = 4
            Const   conDriveTypeRAMDisk = 5
       Constants returned by File.Attributes
            Const   conFileAttrNormal = 0
            Const   conFileAttrReadOnly = 1
            Const   conFileAttrHidden = 2
            Const   conFileAttrSystem = 4
            Const   conFileAttrVolume = 8
            Const   conFileAttrDirectory = 16
            Const   conFileAttrArchive = 32
            Const   conFileAttrAlias = 64
            Const   conFileAttrCompressed = 128
       Constants for opening files
            Const conOpenFileForReading = 1
            Const conOpenFileForWriting = 2
            Const conOpenFileForAppending = 8




Dani Vainstein                                    58
Lab 11.2
   Write the following functions.
   ShowDriveType(objDrive) - Generates a string describing the
   drive type of a given Drive object.
   ShowFileAttr(objFile) - Generates a string describing the
   attributes of a file or folder.
   GenerateDriveInformation(objFSO) – reports about the Drive
   Letter,Path, Type, IsReady, ShareName, VolumeName, TotalSize,
   FreeSpace, AvailableSpace, and SerialNumber.
   GenerateFileInformation(objFile) – File Name, Type, File
   Attributes, Date Created, Last Accessed, Last Modified and Size
   GenerateFolderInformation(objFolder) – Folder Name, Folder
   Attributes, Date Created, Last Accessed, Last Modified and Size




Dani Vainstein                                                       59
Lab 11.1
   Create a Folder in the D: drive, if not exist in
   C: Drive.
   The name of the folder is VBSInfo.
   Create a file in the folder, TestInfo.txt
   The file will contain the report of the program.
   The data will displayed like a table (rows and
   columns with headers) use the vbTab for
   separate the data.
   For getting information about the directories
   and files, please DON’T do it an all drives, select
   only the drive were you created your file.


Dani Vainstein                                       60
Lab 11.1
   Create a Folder in the D: drive, if not exist in
   C: Drive.
   The name of the folder is VBSInfo.
   Create a file in the folder, TestInfo.txt
   The file will contain the report of the program.
   The data will displayed like a table (rows and
   columns with headers) use the vbTab for
   separate the data.
   For getting information about the directories
   and files, please DON’T do it an all drives, select
   only the drive were you created your file.


Dani Vainstein                                       61
What’s Next

   What means error handling.
   When to use On Error statements.
   Using the error object.
   Raising our own errors.


The next session is for advanced users.




Dani Vainstein                            62
Make sure to visit us

 Tutorials
 Articles
 Proikects
 And much more

         www.AdvancedQTP.com



                               63

Más contenido relacionado

La actualidad más candente

Pal gov.tutorial3.session2.xml ns and schema
Pal gov.tutorial3.session2.xml ns and schemaPal gov.tutorial3.session2.xml ns and schema
Pal gov.tutorial3.session2.xml ns and schemaMustafa Jarrar
 
Pal gov.tutorial2.session2.xml dtd's
Pal gov.tutorial2.session2.xml dtd'sPal gov.tutorial2.session2.xml dtd's
Pal gov.tutorial2.session2.xml dtd'sMustafa Jarrar
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLKumar
 
Summer Training In Dotnet
Summer Training In DotnetSummer Training In Dotnet
Summer Training In DotnetDUCC Systems
 
Linked data and the LOCAH project ILI2011
Linked data and the LOCAH project ILI2011Linked data and the LOCAH project ILI2011
Linked data and the LOCAH project ILI2011Bethan Ruddock
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programmingPraveen Chowdary
 
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...Daniele Gianni
 
M05 Metamodel
M05 MetamodelM05 Metamodel
M05 MetamodelDang Tuan
 
Applying Semantic Extensions And New Services To Drupal Sem Tech June 2010
Applying Semantic Extensions And New Services To Drupal   Sem Tech June 2010Applying Semantic Extensions And New Services To Drupal   Sem Tech June 2010
Applying Semantic Extensions And New Services To Drupal Sem Tech June 2010AI4BD GmbH
 
Writing Usable APIs in Practice by Giovanni Asproni
Writing Usable APIs in Practice by Giovanni AsproniWriting Usable APIs in Practice by Giovanni Asproni
Writing Usable APIs in Practice by Giovanni AsproniSyncConf
 
Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)Traitet Thepbandansuk
 
2012 07-jvm-summit-batches
2012 07-jvm-summit-batches2012 07-jvm-summit-batches
2012 07-jvm-summit-batchesWill Cook
 
Extensible and Dynamic Topic Types For DDS (out of date)
Extensible and Dynamic Topic Types For DDS (out of date)Extensible and Dynamic Topic Types For DDS (out of date)
Extensible and Dynamic Topic Types For DDS (out of date)Rick Warren
 
C:\fakepath\buildingblock bbmanifest
C:\fakepath\buildingblock bbmanifestC:\fakepath\buildingblock bbmanifest
C:\fakepath\buildingblock bbmanifestdil12345
 
Pal gov.tutorial2.session5 2.rdfs_jarrar
Pal gov.tutorial2.session5 2.rdfs_jarrarPal gov.tutorial2.session5 2.rdfs_jarrar
Pal gov.tutorial2.session5 2.rdfs_jarrarMustafa Jarrar
 

La actualidad más candente (19)

Pal gov.tutorial3.session2.xml ns and schema
Pal gov.tutorial3.session2.xml ns and schemaPal gov.tutorial3.session2.xml ns and schema
Pal gov.tutorial3.session2.xml ns and schema
 
Pal gov.tutorial2.session2.xml dtd's
Pal gov.tutorial2.session2.xml dtd'sPal gov.tutorial2.session2.xml dtd's
Pal gov.tutorial2.session2.xml dtd's
 
JavaYDL19
JavaYDL19JavaYDL19
JavaYDL19
 
ACE Logo
ACE LogoACE Logo
ACE Logo
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
Summer Training In Dotnet
Summer Training In DotnetSummer Training In Dotnet
Summer Training In Dotnet
 
Linked data and the LOCAH project ILI2011
Linked data and the LOCAH project ILI2011Linked data and the LOCAH project ILI2011
Linked data and the LOCAH project ILI2011
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
 
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...
The DEVS-Driven Modeling Language: Syntax and Semantics Definition by Meta-Mo...
 
M05 Metamodel
M05 MetamodelM05 Metamodel
M05 Metamodel
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Oop
OopOop
Oop
 
Applying Semantic Extensions And New Services To Drupal Sem Tech June 2010
Applying Semantic Extensions And New Services To Drupal   Sem Tech June 2010Applying Semantic Extensions And New Services To Drupal   Sem Tech June 2010
Applying Semantic Extensions And New Services To Drupal Sem Tech June 2010
 
Writing Usable APIs in Practice by Giovanni Asproni
Writing Usable APIs in Practice by Giovanni AsproniWriting Usable APIs in Practice by Giovanni Asproni
Writing Usable APIs in Practice by Giovanni Asproni
 
Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)
 
2012 07-jvm-summit-batches
2012 07-jvm-summit-batches2012 07-jvm-summit-batches
2012 07-jvm-summit-batches
 
Extensible and Dynamic Topic Types For DDS (out of date)
Extensible and Dynamic Topic Types For DDS (out of date)Extensible and Dynamic Topic Types For DDS (out of date)
Extensible and Dynamic Topic Types For DDS (out of date)
 
C:\fakepath\buildingblock bbmanifest
C:\fakepath\buildingblock bbmanifestC:\fakepath\buildingblock bbmanifest
C:\fakepath\buildingblock bbmanifest
 
Pal gov.tutorial2.session5 2.rdfs_jarrar
Pal gov.tutorial2.session5 2.rdfs_jarrarPal gov.tutorial2.session5 2.rdfs_jarrar
Pal gov.tutorial2.session5 2.rdfs_jarrar
 

Similar a B vb script11

EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerJeba Moses
 
1 intro
1 intro1 intro
1 introabha48
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptxSajidTk2
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programmingNitin Kumar Kashyap
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Techglyphs
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfHouseMusica
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.Questpond
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityShubham Narkhede
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
1. Mini seminar intro
1. Mini seminar intro1. Mini seminar intro
1. Mini seminar introLeonid Maslov
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentSVRTechnologies
 

Similar a B vb script11 (20)

Question bank unit i
Question bank unit iQuestion bank unit i
Question bank unit i
 
C# concepts
C# conceptsC# concepts
C# concepts
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
1 intro
1 intro1 intro
1 intro
 
Cs2305 programming paradigms lecturer notes
Cs2305   programming paradigms lecturer notesCs2305   programming paradigms lecturer notes
Cs2305 programming paradigms lecturer notes
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programming
 
OOP
OOPOOP
OOP
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
 
chapter - 1.ppt
chapter - 1.pptchapter - 1.ppt
chapter - 1.ppt
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
1. Mini seminar intro
1. Mini seminar intro1. Mini seminar intro
1. Mini seminar intro
 
C#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course ContentC#.net, C Sharp.Net Online Training Course Content
C#.net, C Sharp.Net Online Training Course Content
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

B vb script11

  • 2. What we learn last session? VBScript string manipulation. VBScript string math. VBScript date manipulation. VBScript Formatting Strings. Dani Vainstein 2
  • 3. Subjects for session 11 The OOP model. Objects. COM objects. Set statement. Nothing keyword CreateObject function. New keyword. FileSystem object. Dani Vainstein 3
  • 4. OOP Model Abstractions Encapsulation Polymorphism Inheritance Reusabillity Dani Vainstein 4
  • 5. OOP Model Abstractions The ability for a program to ignore some aspects of the information it's manipulating, i.e. the ability to focus on the essential. An abstract class cannot be instantiated. An abstract class may contain abstract methods and accessors. An abstract class can be partially implemented, or not at all implemented. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. Dani Vainstein 5
  • 6. OOP Model Encapsulation The ability for the program to hide information about the implementation of a module from its users, i.e. the ability to prevent users from breaking the invariants of the program. The term encapsulation refer to Information hiding in software. Dani Vainstein 6
  • 7. OOP Model Polymorphism Polymorphism is the ability for classes to provide different implementations of methods that are called by the same name. Polymorphism allows a method of a class to be called without regard to what specific implementation it provides. Dani Vainstein 7
  • 8. OOP Model Polymorphism • You might have a class named Road which calls the Drive method of an additional class. • This Car class may be SportsCar, or SmallCar, but both would provide the Drive method. • Though the implementation of the Drive method would be different between the classes, the Road class would still be able to call it, and it would provide results that would be usable and interpretable by the Road class. Dani Vainstein 8
  • 9. OOP Model Inheritance Defining classes as extensions of existing classes. In computer science, the term inheritance may be applied to a variety of situations in which certain characteristics are passed on from one context to another. The term originates with the biological concept of a parent passing on certain traits to a child Dani Vainstein 9
  • 10. Dimensions Area Flanks Shape Perimeter Radious Height *pi Circle Rectangle angles Width Triangle Where is the right place for Volume this action? depth 3D Dani Vainstein 10
  • 11. OOP Model Reusabillity reusability is the likelihood a segment of structured code can be used again to add new functionalities with slight or no modification. Reusable code reduces implementation time, increases the likelihood that prior testing and use has eliminated bugs and localizes code modifications when a change in implementation is required. Subroutines or functions are the simplest form of reuse. A chunk of code is regularly organized using module or namespace. Proponents claim that objects and software components offer a more advanced form of reusability. Dani Vainstein 11
  • 12. Object Model Object. Collection. Container object. Method. Event. Property. Attribute. Dani Vainstein 12
  • 13. Object Model Objects In computer science , an object is a data structure (incorporating data and methods) whose instance is unique and separate from other objects, although it can "communicate" with other objects. In some occasions, some object can be conceived of as a sub program which can communicate with others by receiving or giving instructions based on its, or the other's, data or methods. Data can consist of numbers, literal strings , variables, and references. the object lifetime (or life cycle) of an object in OOP is the time between an object's creation (also known as instantiation or construction) till the object is no longer used, and is destructed or freed. Dani Vainstein 13
  • 14. Object Model Collection An object that contains zero or more objects (member). Collections normally contain objects of the same class. Also referred to as a collection object or an object collection. Collection has normally two single read-only properties, Item and Count you usually use the Item property or method and pass the name or index number of the member. Dani Vainstein 14
  • 15. Object Model Container Object An object that contains other objects from different classes. Collection can have properties and/or methods. Dani Vainstein 15
  • 16. Object Model Methods Method is a function or subroutine that is associated with a class in OPP. Like a function in procedural languages, it may contain a set of program statements that perform an action, and (in most computer languages ) can take a set of input arguments and can return some kind of result. The purpose of a method is to provide a mechanism for changing or accessing information stored in an object of the class. Dani Vainstein 16
  • 17. Object Model Methods A method should preserve invariants associated with the class, and should be able to assume that every invariant is valid on entry to the method A method can have parameters. method may produce output, which are constrained by postconditions of the method. If the arguments to a method do not satisfy their preconditions, a method can raise an exception Dani Vainstein 17
  • 18. Object Model Event In the context of programming, the occurrence of some particular action or the occurrence of a change of state that can be handled by an application or COM object that is invoked in response to the triggering of an event. . For example, the arrival of a message to the SMTP service is an event that can be handled by any number of Applications or objects. Dani Vainstein 18
  • 19. Object Model Property Properties are like smart fields. A property is an information that is associated with an object. Each property has a value. value is a keyword in the syntax for the property definition. The variable value is assigned to the property in the calling code. The type of value must be the same as the declared type of the property to which it is assigned. properties fall into two categories: run-time properties and persistent properties. Dani Vainstein 19
  • 20. Object Model Attribute Each property has attributes. Attributes provide information about the property. For example, the First Name property has the following attributes: Name, Display Name, Description, and Type. Attributes include information such as the data type of the profile property (for example, number, text, decimal, or site term), and whether the property is single-valued (for example, only one First Name entry is allowed per user) or multi-valued. Dani Vainstein 20
  • 21. COM Component Object Model An architecture for defining interfaces (a set of abstract methods and properties that encompass some common purpose) and interaction among objects implemented by widely varying software applications. All COM interfaces are extend and derived from the IUnknown, interface which includes the methods QueryInterface, AddRef, and Release. COM interfaces additionally define a binary signature that acts as a contract between the interface designer and client applications written to use the interface COM classes provide concrete implementations of COM interfaces. Dani Vainstein 21
  • 22. COM IUnknown The fundamental COM interface, which must be extended by every valid COM interface. IUnknown exposes three methods: QueryInterface, used to find out if the object supports a certain interface and return the interface if it does. AddRef, to increment the interface reference count. Release, to decrement the interface reference count. Dani Vainstein 22
  • 23. COM COM Class An implementation of one or more COM interfaces. COM objects are instances of COM classes. Dani Vainstein 23
  • 24. COM COM Interface A pointer to a vtable pointer where the first three methods in that table are QueryInterface, AddRef, and Release. Dani Vainstein 24
  • 25. COM Objects COM Extensions Technologies COM+(Component Services ) ActiveX, OLE SOM, DSOM – IBM’s System object model DCOM (Distributed COM) Distributed COM CORBA – Common Object Request Broker Architecture RMI, JavaBeans – SUN Microsystems technologies. RPC – Remote Procedure Call. Dani Vainstein 25
  • 26. COM objects Where they are? In the registry under HKEY_CLASSES_ROOT you will se all the classes registered in your system. You can find there the Scripting.FileSystemObject Key, Excel.Application key etc All those classes can be used in VBScript. Each class has a description, a CLSID entry and some a version entry. In CLSID you will find the class identifier. If you move to HKEY_CLASSES_ROOTCLSID you will see wich dll’s using this class. For more information search for <registration> Element topic in VBScript documentation. Dani Vainstein 26
  • 27. Set statement Assigns an object reference to a variable or property, or associates a procedure reference with an event. To be valid, object must be an object type consistent with the object being assigned to it. The Dim, Private, Public, or ReDim statements only declare a variable that refers to an object. No actual object is referred to until you use the Set statement to assign a specific object. Generally, when you use Set to assign an object reference to a variable, no copy of the object is created for that variable. Instead, a reference to the object is created. More than one object variable can refer to the same object. Because these variables are references to (rather than copies of) the object, any change in the object is reflected in all variables that refer to it. Dani Vainstein 27
  • 28. Nothing Keyword The Nothing keyword in VBScript is used to disassociate an object variable from any actual object. Use the Set statement to assign Nothing to an object variable. For example: Set MyObject = Nothing Several object variables can refer to the same actual object. When Nothing is assigned to an object variable, that variable no longer refers to any actual object. When several object variables refer to the same object, memory and system resources associated with the object to which the variables refer are released only after all of them have been set to Nothing, either explicitly using Set, or implicitly after the last object variable set to Nothing goes out of scope. Dani Vainstein 28
  • 29. CreateObject Function CreateObject(servername.typename [, location]) Creates and returns a reference to an Automation object. servername - Required. The name of the application providing the object. typename - Required. The type or class of the object to create. location - Optional. The name of the network server where the object is to be created. Automation servers provide at least one type of object. For example, a word-processing application may provide an application object, a document object, and a toolbar object. Dani Vainstein 29
  • 30. CreateObject Function For example, a word-processing application may provide an application object, a document object, and a toolbar object. To create an Automation object, assign the object returned by CreateObject to an object variable: Dim ExcelSheet Set ExcelSheet = CreateObject("Excel.Sheet") Dani Vainstein 30
  • 31. CreateObject Function Once an object is created, refer to it in code using the object variable you defined. you can access properties and methods of the new object using the object variable. Creating an object on a remote server can only be accomplished when Internet security is turned off. You can create an object on a remote networked computer by passing the name of the computer to the servername argument of CreateObject. That name is the same as the machine name portion of a share name. For a network share named "myserverpublic", the servername is "myserver". In addition, you can specify servername using DNS format or an IP address. Dani Vainstein 31
  • 32. CreateObject Function Summary Creating an object Set myDoc = CreateObject (“Word.Document”) Using The object MyDoc.content = “abc” MyDoc.SaveAs “Doc1.doc” MyDoc.Close Free the object Set Mydoc = Nothing Type COM Library Class Dani Vainstein 32
  • 33. FileSystemObject Object Basics When writing scripts it's often important to add, move, change, create, or delete folders and files. It may also be necessary to get information about and manipulate drives attached to the machine. Scripting allows you to process drives, folders, and files using the FileSystemObject (FSO) object model. Dani Vainstein 33
  • 34. New Keyword Keyword used to create a new instance of a class. If objectvar contained a reference to an object, that reference is released when the new one is assigned. The New keyword can only be used to create an instance of a class. Using the New keyword allows you to concurrently create an instance of a class and assign it to an object reference variable. The variable to which the instance of the class is being assigned must already have been declared with the Dim (or equivalent) statement. Dani Vainstein 34
  • 35. FileSystemObejct Object Model The FileSystemObject (FSO) object model allows you to use the familiar object.method syntax with a rich set of properties, methods, and events to process folders and files. The FSO object model gives to the QTP the ability to create, alter, move, and delete folders, or to detect if particular folders exist, and if so, where. You can also find out information about folders, such as their names, the date they were created or last modified, and so forth. The FSO object model also makes it easy to process files. When processing files, the primary goal is to store data in a space- and resource-efficient, easy-to-access format. You need to be able to create files, insert and change the data, and output (read) the data. Dani Vainstein 35
  • 36. FileSystemObejct Object Model The FSO object model, which is contained in the Scripting type library (Scrrun.dll), supports text file creation and manipulation through the TextStream object. Although it does not yet support the creation or manipulation of binary files, future support of binary files is planned. Dani Vainstein 36
  • 37. FileSystemObject Objects Main Main object. Contains methods and properties that allow you to create, delete, gain information about, and generally manipulate drives, folders, and files. Many of the methods associated with this object duplicate those in other FSO objects; they are provided for convenience. Dani Vainstein 37
  • 38. FileSystemObject Objects Drive Object Contains methods and properties that allow you to gather information about a drive attached to the system, such as its share name and how much room is available. Note that a "drive" isn't necessarily a hard disk, but can be a CD-ROM drive, a RAM disk, and so forth. A drive doesn't need to be physically attached to the system; it can be also be logically connected through a network. Dani Vainstein 38
  • 39. FileSystemObject Objects Drive Collection Provides a list of the drives attached to the system, either physically or logically. The Drives collection includes all drives, regardless of type. Removable-media drives need not have media inserted for them to appear in this collection. Dani Vainstein 39
  • 40. FileSystemObject Objects File Object Contains methods and properties that allow you to create, delete, or move a file. Also allows you to query the system for a file name, path, and various other properties. Dani Vainstein 40
  • 41. FileSystemObject Objects Files Collection Provides a list of all files contained within a folder. Dani Vainstein 41
  • 42. FileSystemObject Objects Folder Object Contains methods and properties that allow you to create, delete, or move folders. Also allows you to query the system for folder names, paths, and various other properties. Dani Vainstein 42
  • 43. FileSystemObject Objects Folders Collection Provides a list of all the folders within a Folder. Dani Vainstein 43
  • 44. FileSystemObject Objects TextStream Object Allows you to read and write text files. Dani Vainstein 44
  • 45. Programming the FileSystemObject Use the CreateObject method to create a FileSystemObject object. Use the appropriate method on the newly created object. Access the object's properties. Set objFSO = CreateObject("Scripting.FileSystemObject") Scripting is the name of the type library and FileSystemObject is the name of the object that you want to create. Dani Vainstein 45
  • 46. Accessing Existing Drives, Files, and Folders To gain access to an existing drive, file, or folder, use the appropriate "get" method of the FileSystemObject object: GetDrive GetFolder GetFile Do not use the "get" methods for newly created objects, since the "create" functions already return a handle to that object. For example, if you create a new folder using the CreateFolder method, don't use the GetFolder method to access its properties, such as Name, Path, Size, and so forth. Just set a variable to the CreateFolder function to gain a handle to the newly created folder, then access its properties, methods, and events. Dani Vainstein 46
  • 47. Accessing the Object's Properties Once you have a handle to an object, you can access its properties. For example, to get the name of a particular folder, first create an instance of the object, then get a handle to it with the appropriate method (in this case, the GetFolder method, since the folder already exists). Dani Vainstein 47
  • 48. Working with Drives and Folders With the FileSystemObject (FSO) object model, you can work with drives and folders programmatically just as you can in the Windows Explorer interactively. You can copy and move folders, get information about drives and folders, and so forth. Dani Vainstein 48
  • 49. Getting Information About Drives The Drive object allows you to gain information about the various drives attached to a system, either physically or over a network. Dani Vainstein 49
  • 50. Getting Information About Drives The total size of the drive in bytes (TotalSize property). How much space is available on the drive in bytes (AvailableSpace or FreeSpace properties). What letter is assigned to the drive (DriveLetter property). What type of drive it is, such as removable, fixed, network, CD-ROM, or RAM disk (DriveType property). The drive's serial number (SerialNumber property). The type of file system the drive uses, such as FAT, FAT32, NTFS, and so forth (FileSystem property). Whether a drive is available for use (IsReady property) The name of the share and/or volume (ShareName and VolumeName properties) The path or root folder of the drive (Path and RootFolder properties) Dani Vainstein 50
  • 51. Working With Folders Create a folder - FileSystemObject.CreateFolder Delete a folder - Folder.Delete or FileSystemObject.DeleteFolder Move a folder - Folder.Move or FileSystemObject.MoveFolder Copy a folder - Folder.Copy or FileSystemObject.CopyFolder Retrieve the name of a folder - Folder.Name Find out if a folder exists on a drive - FileSystemObject.FolderExists Get an instance of an existing Folder object - FileSystemObject.GetFolder Find out the name of a folder's parent folder - FileSystemObject.GetParentFolderName Find out the path of system folders - FileSystemObject.GetSpecialFolder Dani Vainstein 51
  • 52. Working With Files There are two major categories of file manipulation Creating, adding, or removing data, and reading files. Moving, copying, and deleting files. Dani Vainstein 52
  • 53. Creating Files There are three ways to create an empty text file. The first way is to use the CreateTextFile method. The second way to create a text file is to use the OpenTextFile method of the FileSystemObject object with the ForWriting flag set. A third way to create a text file is to use the OpenAsTextStream method with the ForWriting flag set. Dani Vainstein 53
  • 54. Adding Data to the File Once the text file is created, add data to the file using the following three steps: Open the text file. Write the data. Close the file. To open an existing file, use either the OpenTextFile method of the FileSystemObject object or the OpenAsTextStream method of the File object. To write data to the open text file, use the Write, WriteLine, or WriteBlankLines methods of the TextStream object according to your task. To close an open file, use the Close method of the TextStream object. Note The newline character contains a character or characters to advance the cursor to the beginning of the next line. Be aware that the end of some strings may already have such nonprinting characters. Dani Vainstein 54
  • 55. Reading Files To read data from a text file, use the Read, ReadLine, or ReadAll method of the TextStream object. If you use the Read or ReadLine method and want to skip to a particular portion of data, use the Skip or SkipLine method. The resulting text of the read methods is stored in a string which can be displayed in a control, parsed by string functions (such as Left, Right, and Mid), concatenated, and so forth. Dani Vainstein 55
  • 56. Moving, Copying, and Deleting Files The FSO object model has two methods each for moving, copying, and deleting files Move a file - File.Move or FileSystemObject.MoveFile Copy a file - File.Copy or FileSystemObject.CopyFile Delete a file - File.Delete or FileSystemObject.DeleteFile Dani Vainstein 56
  • 57. Lab 11.1 Tip Const DRV_UNKNOWN = 0 Const DRV_REMOVABLE = 1 Const DRV_FIXED = 2 Const DRV_NETWORK = 3 Const DRV_CDROM = 4 Const DRV_RAMDISK = 5 Dani Vainstein 57
  • 58. Lab 11.2 Declare the follow constants : Constants returned by Drive.DriveType Const conDriveTypeRemovable = 1 Const conDriveTypeFixed = 2 Const conDriveTypeNetwork = 3 Const conDriveTypeCDROM = 4 Const conDriveTypeRAMDisk = 5 Constants returned by File.Attributes Const conFileAttrNormal = 0 Const conFileAttrReadOnly = 1 Const conFileAttrHidden = 2 Const conFileAttrSystem = 4 Const conFileAttrVolume = 8 Const conFileAttrDirectory = 16 Const conFileAttrArchive = 32 Const conFileAttrAlias = 64 Const conFileAttrCompressed = 128 Constants for opening files Const conOpenFileForReading = 1 Const conOpenFileForWriting = 2 Const conOpenFileForAppending = 8 Dani Vainstein 58
  • 59. Lab 11.2 Write the following functions. ShowDriveType(objDrive) - Generates a string describing the drive type of a given Drive object. ShowFileAttr(objFile) - Generates a string describing the attributes of a file or folder. GenerateDriveInformation(objFSO) – reports about the Drive Letter,Path, Type, IsReady, ShareName, VolumeName, TotalSize, FreeSpace, AvailableSpace, and SerialNumber. GenerateFileInformation(objFile) – File Name, Type, File Attributes, Date Created, Last Accessed, Last Modified and Size GenerateFolderInformation(objFolder) – Folder Name, Folder Attributes, Date Created, Last Accessed, Last Modified and Size Dani Vainstein 59
  • 60. Lab 11.1 Create a Folder in the D: drive, if not exist in C: Drive. The name of the folder is VBSInfo. Create a file in the folder, TestInfo.txt The file will contain the report of the program. The data will displayed like a table (rows and columns with headers) use the vbTab for separate the data. For getting information about the directories and files, please DON’T do it an all drives, select only the drive were you created your file. Dani Vainstein 60
  • 61. Lab 11.1 Create a Folder in the D: drive, if not exist in C: Drive. The name of the folder is VBSInfo. Create a file in the folder, TestInfo.txt The file will contain the report of the program. The data will displayed like a table (rows and columns with headers) use the vbTab for separate the data. For getting information about the directories and files, please DON’T do it an all drives, select only the drive were you created your file. Dani Vainstein 61
  • 62. What’s Next What means error handling. When to use On Error statements. Using the error object. Raising our own errors. The next session is for advanced users. Dani Vainstein 62
  • 63. Make sure to visit us Tutorials Articles Proikects And much more www.AdvancedQTP.com 63