home *** CD-ROM | disk | FTP | other *** search
-
-
- SXTNVIEW.DOC
-
- SXTNVIEW - SXTN Database Viewer Sample Application
-
- The SXTNVIEW program is intended as a sample application to
- demonstrate the use of the DLL interface functions to access the
- SXT databases. Each SXT windows version provides its specific DLL
- (CFTNWIN.DLL, CSTNWIN.DLL, ...) together with the necessary C/C++
- header file (CFTNWIN.H, CSTNWIN.H, ...) and an import library
- (CFTNWIN.LIB, CSTNWIN.LIB, ...) that can be linked to your
- programs. SXTNVIEW is a very simple application written in Visual
- Basic with complete source code included. SXTNVIEW works with all
- SXT DLL's and demonstrates the access to all SXT database types.
-
- To run SXTNVIEW, the Visual Basic runtime library VBRUN300.DLL
- (not included in this package) installed in the \windows\system
- directory is required. It is also necessary to copy the SXT DLL's
- to the \windows\system directory.
-
- After starting SXTNVIEW you have to select the SXT program type
- and the database from the file dialog box. Select one *.dbf file
- that belongs to the project you want to view. After that you can
- view in two list boxes the items (functions/data types), either
- all or only the defined ones, and the filenames by pressing push
- buttons next to these list boxes. By a double click on an item
- you get its location (filename, line number) where it is defined/
- first found. By a double click on a filename you get a list of
- all defined items in that file. You can also directly type the
- name of an item into the 'Search for' text box and start a search
- with the push button. If an itemname is in the search box you can
- press the 'Get Called Item' button to retrieve all items which
- are called from the item.
-
-
- DLL INTERFACE FUNCTIONS
-
- The following description is given for the CFT version but
- applies in the same way to all other SXT programs. The user who
- calls one of these functions has to ensure that the calling
- parameters are large enough to hold the resulting value. In
- general, the strings should be a minimum of 300 characters long
- (char location[300], char name[300], ...).
-
- Some functionality is split into a pair of two closely related
- functions, like cftnGetFirstName() and cftnGetNextName(). The
- user has to ensure that they are called in a direct sequence and
- that there are no intermediate calls, also from other
- applications. Otherwise the results will be incorrect. The reason
- for the split of the functionality is that it is not possible to
- determine the amount of memory to hold the results of the
- function call in advance by the calling function. It would have
- been possible to grow the memory dynamically during search
- operation by the DLL, return a pointer to the memory and leave it
- to the application to free it after use. This would work with C
- but not with Visual Basic or application macro languages like
- Word Basic and Visual Basic for Applications.
-
-
- - 1 -
-
-
-
- The return values of all DLL functions are 101 if successful, all
- other values mean that something went wrong (e.g. database not
- found, database is not a SXT database, item does not exist, out
- of memory, ...).
-
- Following is a description of the DLL-functions:
-
- LONG FAR PASCAL _export cftnGetLocation(LPSTR dbfname, LPSTR
- name, LPSTR location);
- Get the location of a specific item, if the return value is 101 a
- location for item was found.
- dbfname the database name
- name the name of the item
- location contains a string with the location
- (filename<space>line number) of the item
-
- LONG FAR PASCAL _export cftnGetFirstName(LPSTR dbfname, LPSTR
- name);
- Get the first item from the database, must be called once before
- cftnGetNextName.
- dbfname the database name
- name contains a string with the itemname
-
- LONG FAR PASCAL _export cftnGetNextName(LPSTR dbfname, LPSTR
- name);
- Get the next item from the database, must be called after
- cftnGetFirstName, as long as the return value is 101 a new name
- is retrieved.
- dbfname the database name
- name contains a string with the itemname
-
- LONG FAR PASCAL _export cftnGetFirstDefName(LPSTR dbfname, LPSTR
- name);
- Get the first defined item from the database, must be called once
- before cftnGetNextDefName.
- dbfname the database name
- name contains a string with the defined itemname
-
- LONG FAR PASCAL _export cftnGetNextDefName(LPSTR dbfname, LPSTR
- name);
- Get the next defined item from the database, must be called after
- cftnGetFirstDefName, as long as the return value is 101 a new
- name is retrieved.
- dbfname the database name
- name contains a string with the defined itemname
-
- LONG FAR PASCAL _export cftnGetFirstCalledItem(LPSTR dbfname,
- LPSTR caller, LPSTR calleditem, LPSTR location);
- Get the first called item of caller from the database, must be
- called once before cftnGetNextCalledItem.
- dbfname the database name
- caller contains a string with the name of the caller
- calleditem contains a string with the first called item
- location contains a string with the location
- (filename<space>line number) of the item
-
-
- - 2 -
-
-
-
- LONG FAR PASCAL _export cftnGetNextCalledItem(LPSTR dbfname,
- LPSTR caller, LPSTR calleditem, LPSTR location);
- Get the next called item of caller from the database, must be
- called after cftnGetFirstCalledItem, as long as the return value
- is 101 a new called item is retrieved.
- dbfname the database name
- caller contains a string with the name of the caller
- calleditem contains a string with the first called item
- location contains a string with the location
- (filename<space>line number) of the item
-
- LONG FAR PASCAL _export cftnGetFirstFile(LPSTR dbfname, LPSTR
- filename);
- Get the first file from the database, must be called once before
- cftnGetFirstFile.
- dbfname the database name
- name contains a string with the filename
-
- LONG FAR PASCAL _export cftnGetNextFile(LPSTR dbfname, LPSTR
- filename);
- Get the next file from the database, must be called after
- cftnGetFirstFile, as long as the return value is 101 a new file
- is retrieved.
- dbfname the database name
- name contains a string with the filename
-
-
- THE VISUAL BASIC EXAMPLE 'SXTNVIEW'
-
- Following is a short, incomplete extract from the SXTNVIEW Visual
- Basic source code to show some implementation details.
-
- 1. DLL-FUNCTION DECLARATION
- The DLL-functions have to be declared in the following way:
-
- Declare Function cftnGetLocation Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal searchname$, ByVal location$) As Long
- Declare Function cftnGetFirstName Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
- Declare Function cftnGetNextName Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
- Declare Function cftnGetFirstDefName Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
- Declare Function cftnGetNextDefName Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
- Declare Function cftnGetFirstCalledItem Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal caller$, ByVal calleditem$, ByVal location$) As
- Long
- Declare Function cftnGetNextCalledItem Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal caller$, ByVal calleditem$, ByVal location$) As
- Long
- Declare Function cftnGetFirstFile Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
- Declare Function cftnGetNextFile Lib "cftnwin.dll" (ByVal
- dbfname$, ByVal location$) As Long
-
-
- - 3 -
-
-
- (similar for the other DLL's)
-
- 2. CALLING THE RIGTH SXT FUNCTION
- The SXTNVIEW functions call for every DLL-related function an
- intermediate function where, according to the selected SXT type,
- the right DLL-function is called. This simplifies the source
- code.
-
- Function sxtnGetFirstName (dbfname$, location$) As Long
- If option1.Value = True Then
- sxtnGetFirstName = cftnGetFirstName(dbfname, location)
- ElseIf option2.Value = True Then
- sxtnGetFirstName = cstnGetFirstName(dbfname, location)
- ElseIf option3.Value = True Then
- sxtnGetFirstName = dftnGetFirstName(dbfname, location)
- ElseIf option4.Value = True Then
- sxtnGetFirstName = fftnGetFirstName(dbfname, location)
- ElseIf option5.Value = True Then
- sxtnGetFirstName = lftnGetFirstName(dbfname, location)
- End If
- End Function
- (similar for the other SXT DLL functions)
-
- 3. FUNCTION TO RETRIEVE THE LOCATION OF A SPECIFIC ITEM
- Sub Command2_Click ()
- Dim dbfname As String
- Dim searchname As String
- Dim result As String
- result = String$(300, 0)
- dbfname = label1.Caption
- searchname = text1.Text
- If Left(dbfname$, 1) <> "" And Left(searchname$, 1) <> "" Then
- retval = sxtnGetLocation(dbfname$, searchname$, result$)
- label7.Caption = result$
- End If
- End Sub
-
- 4. FUNCTION TO RETRIEVE ALL FILES
- Sub Command3_Click ()
- Dim string1 As String
- Dim result As String
- string1$ = label1.Caption
- result = String$(300, 0)
- list2.Clear
- If Left(string1$, 1) <> "" Then
- retval = sxtnGetFirstFile(string1$, result$)
- If retval = 101 Then
- list2.AddItem result$
- Do
- retval = sxtnGetNextFile(string1$, result$)
- If retval = 101 Then
- list2.AddItem result$
- Else
- Exit Do
- End If
- Loop While retval = 101
-
-
- - 4 -
-
-
- End If
- End If
- label6.Caption = Str$(list2.ListCount) + " files"
- End Sub
-
- 5. FUNCTION TO RETRIEVE ALL ITEMS
- Sub Command4_Click ()
- Dim dbfname As String
- Dim result As String
- dbfname$ = label1.Caption
- result = String$(300, 0)
- list1.Clear
- If Left(dbfname$, 1) <> "" Then
- retval = sxtnGetFirstName(dbfname$, result$)
- If retval = 101 Then
- list1.AddItem result$
- Do
- retval = sxtnGetNextName(dbfname$, result$)
- If retval = 101 Then
- list1.AddItem result$
- Else
- Exit Do
- End If
- Loop While retval = 101
- End If
- End If
- label5.Caption = Str$(list1.ListCount) + " items"
- End Sub
-
- 6. FUNCTION TO RETRIEVE ALL DEFINED ITEMS
- Sub Command5_Click ()
- Dim dbfname As String
- Dim result As String
- dbfname$ = label1.Caption
- result = String$(300, 0)
- list1.Clear
- If Left(dbfname$, 1) <> "" Then
- retval = sxtnGetFirstDefName(dbfname$, result$)
- If retval = 101 Then
- list1.AddItem result$
- Do
- retval = sxtnGetNextDefName(dbfname$, result$)
- If retval = 101 Then
- list1.AddItem result$
- Else
- Exit Do
- End If
- Loop While retval = 101
- End If
- End If
- label5.Caption = Str$(list1.ListCount) + " defined items"
- End Sub
-
- 7. FUNCTION TO RETRIEVE ALL ITEMS DEFINED IN A SPECIFIC FILE
- Sub List2_DblClick ()
- Dim dbfname As String
-
-
- - 5 -
-
-
- Dim searchname As String
- Dim result As String
- dbfname$ = label1.Caption
- result = String$(300, 0)
- FileName = list2.List(list2.ListIndex)
- list1.Clear
- If Left(dbfname$, 1) <> "" Then
- retval = sxtnGetFirstDefName(dbfname$, result$)
- If retval = 101 Then
- searchname = Left$(result, InStr(1, result, Chr$(0),1) - 1)
- result = String$(300, 0)
- retval = sxtnGetLocation(dbfname$, searchname$, result$)
- If retval = 101 Then
- If InStr(1, result, FileName, 1) Then
- list1.AddItem searchname$
- End If
- End If
- End If
-
- Do
- retval = sxtnGetNextDefName(dbfname$, result$)
- If retval = 101 Then
- searchname = Left$(result, InStr(1, result, Chr$(0),1)-1)
- result = String$(300, 0)
- retval = sxtnGetLocation(dbfname$, searchname$, result$)
- If retval = 101 Then
- If InStr(1, result, FileName, 1) Then
- list1.AddItem searchname$
- End If
- End If
- Else
- Exit Do
- End If
- Loop While retval = 101
- End If
- label5.Caption = Str$(list1.ListCount) + " defined items in "
- + FileName
- End Sub
-
- 8. FUNCTION TO RETRIEVE ALL CALLED ITEMS OF A SPECIFIC ITEM
- Sub Command6_Click ()
- Dim dbfname As String
- Dim caller As String
- Dim location As String
- Dim calleditem As String
- dbfname$ = label1.Caption
- calleditem = String$(300, 0)
- location = String$(300, 0)
- caller = text1.Text
- list1.Clear
- If Left(dbfname$, 1) <> "" Then
- retval = sxtnGetFirstCalledItem(dbfname$, caller$,
- calleditem$, location$)
- If retval = 101 Then
- list1.AddItem calleditem$
- Do
-
-
- - 6 -
-
-
- retval = sxtnGetNextCalledItem(dbfname$, caller$,
- calleditem$, location$)
- If retval = 101 Then
- list1.AddItem calleditem$
- Else
- Exit Do
- End If
- Loop While retval = 101
- End If
- End If
- label5.Caption = Str$(list1.ListCount) + " called items"
- End Sub
-
-
- FURTHER DEVELOPMENT
-
- The above example demonstrates the capabilites of the SXT-DLL's.
- They can be called from any Windows application, e.g. MS Word for
- Windows, MS Excel, MS Access, CodeWright Editor, or from user
- developed applications.
-
-
-
- Copyright (C) Juergen Mueller (J.M.) 1988-1995.
- All rights reserved world-wide.
-
- SXT (TM) SOFTWARE EXPLORATION TOOLS
- SXTWIN (TM) SOFTWARE EXPLORATION TOOLS for Windows
-
-
- (THIS DOCUMENT HAS 7 PAGES)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - 7 -
-