Announcement

Collapse
No announcement yet.

New Submission!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • New Submission!

    Been working long and hard at this, so much so that I havn't kept up with messages sent to me (banjo picking) or much of anything else. So I want to present what I have, and I guarantee it will take some time to get through it, as it tries to tackle some of the really nasty issues of converting OOP code to procedure calls.

    What stopped me on the original conversion of last week was the following…

    TxtText1.Text = “You Clicked cmdButton Whatever…”

    Following are my thoughts on a general solution. Every line of code the VB Converter looks at is going to have to be examined to determine what general category of code line it is. Some possibilities are assignment statements such as…

    I=1

    Or perhaps the txtText1.text = “…..” above. Both are assignment statements. But what about…

    Select Case iNumber

    Or

    For I=1 To 100000

    These I would catagorize as ‘Block’ statements. Or what about this…

    Erase iArr

    Or

    Dim iNumber As Long


    Or

    Kill strFileName

    Or

    Call ClearArrays()


    These are procedure calls or calls using reserved words. So what I’m saying is that I believe we need some kind of data structure to describe a vb code line in preparation for its eventual parsing into some kind of PB statement or procedure call.

    By the way, I’ve never done anything like this before, so the only real qualifications I have for it are enthusiasm and the ability to write reams of code!

    So anyway, I agonized over this issue of a data structure to describe a line of code quite a bit; creating types, erasing types, etc. The problem is that the fields of a structure (TYPE) to describe a code line pretty much depend on the above catagorization of what general type of line it is. For example, if a code line is an assignment statement it will have an equal sign in it and a left and right term. These fields would be meaningless if it is just a subroutine call such as ‘Call MyProc()’. So to make a long story short I decided to use a UNION to describe a code line. A structure (TYPE) will be included in the UNION for all the general types of statements that exist. Here is the general idea…

    Code:
    Type Term
      szTerm As Asciiz*256                    '256
    End Type
    
    Type vbAssignmentStatement     
      iType                        As Long
      LeftTerm                     As Term    '256
      RightTerm                    As Term    '256
      LeftTermIdentity             As Long    '  4  1=%NumericConstant, 2=%StringConstant, 3=vbObject….
      RightTermIdentity            As Long    '  4  ditto
    End Type
    
    Type vbStatement
      iType                        As Long
      szReservedWord               As Asciiz*16             '16
      szArguements                 As Asciiz*48             '48
    End Type
    
    Type vbBlockStatement
      iType                        As Long
      szStatement                  As Asciiz*32
    End Type
    
    Union vbCodeLine
      iType                        As Long
      vbAssignment                 As vbAssignmentStatement
      vbVerb                       As vbStatement
      vbBlock                      As vbBlockStatement
    End Union
    This way, a parsing routine, on a first cut through, can figure out what a line ‘is’, then pass its handling off to the next routine in sequence. Note that in forming a UNION to be used in this way one places some kind of integer class variable as the 1st member of every TYPE that will be contained in the UNION.

    The next concept necessary to a solution of the problem I believe is the creation of a symbol table that contains information on every symbol defined by the programmer of the VB program to be converted. In general, the symbol table will contain the names of all controls on a Form such as textboxes, the names of all variables, and the names of all sub routines, event procedures, etc. The idea being that at some point terms are going to have to be taken apart, i.e., parsed, and the SymbolTable is where the program will have to look to determine if it is dealing with an integer variable such as ‘i’, or an object such as a listbox, button, or textbox.

    In working with the code I posted last week I found the Windows GUI environment to be too awkward for me to agonize through these concepts and difficulties, and I wanted the familiarity of a plain old console screen. So I tore a lot of the code out of that earlier example and set it up to run with the Console Compiler. There were some GDI calls to complicate things (converting twips to pixels), so I ended up copying a few equates and declares out of Win32Api.inc so that my Console program would run. These and a few other items I didn’t want to spend much time scrolling through all the time I stuck in an include file. So below is a console program I call CCParse.bas. You'll want to set your console screen to fit it as on the first pass through you'll probably get gibberish. Note that it reads frmVBConvert.frm, so look down in PBMain() at the bottom and change this line to wherever you have frmVBConvert.frm

    szFileToConvert="frmVBConvert.frm"

    As you can see, I just put it with the program itself. Perhaps I ought to repost the frmVBConvert.frm file I'm using, then the program

    'frmVBConvert
    Code:
    VERSION 5.00
    Begin VB.Form frmVBConvert 
       Caption         =   "This Is A Visual Basic Form"
       ClientHeight    =   3195
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   2  'CenterScreen
       Begin VB.TextBox txtText1 
          Height          =   435
          Left            =   630
          TabIndex        =   3
          Top             =   2160
          Width           =   3285
       End
       Begin VB.CommandButton cmdButton3 
          Caption         =   "cmdButton3"
          Height          =   495
          Left            =   1440
          TabIndex        =   2
          Top             =   1470
          Width           =   1695
       End
       Begin VB.CommandButton cmdButton2 
          Caption         =   "cmdButton2"
          Height          =   495
          Left            =   1440
          TabIndex        =   1
          Top             =   840
          Width           =   1695
       End
       Begin VB.CommandButton cmdButton1 
          Caption         =   "cmdButton1"
          Height          =   495
          Left            =   1440
          TabIndex        =   0
          Top             =   210
          Width           =   1695
       End
    End
    Attribute VB_Name = "frmVBConvert"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Sub cmdButton1_Click()
      txtText1.Text = "You Clicked cmdButton1 (the top button)!"
    End Sub
    
    Private Sub cmdButton2_Click()
      txtText1.Text = "You Clicked cmdButton2 (the middle button)!"
    End Sub
    
    Private Sub cmdButton3_Click()
      txtText1.Text = "You Clicked cmdButton3 (the bottom button)!"
    End Sub
    and here's a real whopper! (Console Compiler Program!) Note I added voluminous comments to many of the critical conversion procedures to explain what they are doing. I hope it helps!

    Code:
    #Compile Exe
    #Dim All
    #Include "CCParse.inc"
    
    'Enumeration                  vbSymbolTable.iGeneralType
    %SCALER_VARIABLE              = 0
    %COMPLEX_VARIABLE             = 1
    %OBJECT_VARIABLE              = 2
    %PROCEDURE                    = 3
    
    'Enumeration                  Union vbCodeLine.iType
    %Assignment                   =  0
    %vbStatement                  =  1
    %vbBlockStatement             =  2
    %CallProcedure                =  3
    
    'Enumeration Term             (for iIdentifyTerm() Function
    '                             and vbAssignmentStatement.LeftTermIdentity
    '                             and vbAssignmentStatement.RightTermIdentity
    %iIdentify_Term_Error         =  0
    %NumericConstant              =  1
    %StringConstant               =  2
    %vbObject                     =  3
    %Integer                      =  4
    %Long                         =  5
    %Single                       =  6
    %Double                       =  7
    %Currency                     =  8
    %Variant                      =  9
    
    Type vbObject
      szObject                    As Asciiz*24
      szName                      As Asciiz*32
      szCaption                   As Asciiz*64
      szSdkControl                As Asciiz*16
      szEquate                    As Asciiz*64
      iBegin                      As Long
      iEnd                        As Long
      Width                       As Long
      Height                      As Long
      X                           As Long
      Y                           As Long
      TabIndex                    As Long
      iCountEvents                As Long
      dwExStyle                   As Dword
      dwStyle                     As Dword
    End Type
    
    Type vbProcedure
      szType                      As Asciiz*16   'Can be Sub or Function
      iType                       As Long        '0=Sub / 1=Function
      iBegin                      As Long        'What line in frm file?
      iEnd                        As Long        'Line # of End Sub or End Function
      blnContainsObject           As Long        '%TRUE / %FALSE Does the string contain a control in the *.frm file
      blnContainsUnderscore       As Long        'Is there an underscore in the name?
      blnContainsEventName        As Long        'Event name found in string?
      szObjectName                As Asciiz*16   'Name of control if event procedure for control
      szSdkObjectType             As Asciiz*16   'button, edit, static, listbox, etc
      szEventName                 As Asciiz*16   'Click, Keypress, Change, etc
      szOriginalSymbol            As Asciiz*64
      szNewSymbol                 As Asciiz*64
      blnRequiresWMCommand        As Long        'Will this procedure be routed from WM_COMMAND message?
      blnEventProcedure           As Long        'Using the above gleaned info, is it an Event Procedure (%TRUE / %FALSE)?
    End Type
    
    Type vbSymbolTable
      szSymbol                    As Asciiz*64   'e.g, txtFirstName, iNumber, strDate, etc.
      iGeneralType                As Long        'enumeration, i.e., simple scaler variable=0, complex variable=1, object variable=2, procedure=3
      szSpecificType              As Asciiz*24   '"TextBox", "CommonDialog", "Database", "Integer", "String", "Variant", "Sub", "Function", etc.
      blnArray                    As Long        'TRUE/FALSE. Could be an array of almost anything, e.g., textboxes, databases, integers, blnSymbolTables, whatever.
      szSdkType                   As Asciiz*16   'edit,button, etc.
      Scope                       As Long        '0=Local, 1=Form, 2=Public, 3=Static
      szEquate                    As Asciiz*64   'Put equate here if its an object
    End Type
    
    Type Term
      szTerm As Asciiz*256                    '256
    End Type
    
    Type vbAssignmentStatement     
      iType                        As Long
      LeftTerm                     As Term    '256
      RightTerm                    As Term    '256
      LeftTermIdentity             As Long    '  4  1=%NumericConstant, 2=%StringConstant, 3=vbObject, 4=%Integer, 5=%Long, 6=%Single, 7=%Double, etc
      RightTermIdentity            As Long    '  4  ditto
    End Type
    
    Type vbStatement
      iType                        As Long
      szReservedWord               As Asciiz*16             '16
      szArguements                 As Asciiz*48             '48
    End Type
    
    Type vbBlockStatement
      iType                        As Long
      szStatement                  As Asciiz*32
    End Type
    
    Union vbCodeLine
      iType                        As Long
      vbAssignment                 As vbAssignmentStatement
      vbVerb                       As vbStatement
      vbBlock                      As vbBlockStatement
    End Union
    
    Function TwipsPerPixelX() As Single
      Dim lngDC As Long
    
      lngDC = GetDC(%HWND_DESKTOP)
      TwipsPerPixelX=1440&/GetDeviceCaps(lngDC,%LOGPIXELSX)
      Call ReleaseDC(%HWND_DESKTOP,lngDC)
    End Function
    
    
    Function TwipsPerPixelY() As Single     'blasted vb dimensions
      Dim lngDC As Long                     'are in Twips!!!!!!!!!
    
      lngDC=GetDC(%HWND_DESKTOP)
      TwipsPerPixelY=1440&/GetDeviceCaps(lngDC,%LOGPIXELSY)
      Call ReleaseDC(%HWND_DESKTOP,lngDC)
    End Function
    
    
    Function strGetObjName(strArr() As String, iRec As Long) As String
      Local iSpace,iLenStr,iNum As Long
      Register i As Long
    
      iLenStr=Len(strArr(iRec))
      For i=iLenStr -2 To 1 Step -1
        If Mid$(strArr(iRec),i,1)=" " Then
           iSpace=i
           Exit For
        End If
      Next i
    
      strGetObjName=Trim$(Right$(strArr(iRec),iLenStr-iSpace))
    End Function
    
    
    Function strGetVariableType(strDeclaration As String) As String
      Local iLenStr,iSpace As Long
      Register i As Long
    
      iLenStr=Len(strDeclaration)
      For i=iLenStr To 1 Step -1
        If Mid$(strDeclaration,i,1)=" " Then
           iSpace=i
           Exit For
        End If
      Next i
    
      strGetVariableType=Trim$(Right$(strDeclaration,iLenStr-iSpace))
    End Function
    
    
    Function blnLoadObjProperties(strArr() As String, vbObj() As vbObject) As Long
      Local blnFound,iCtr,iStart,i,iPos As Long
      Register j As Long, k As Long
    
      'Print
      'Print "Entering blnLoadObjProperties()"
      'Find beginning and end of Form properties
      For i=0 To Ubound(strArr,1)
        If Instr(strArr(i),"Begin VB.Form") Then
           vbObj(0).iBegin=i
           blnFound=%TRUE
           Iterate For
        End If
        If blnFound Then
           If Instr(strArr(i),"Begin ") Then
              vbObj(0).iEnd=i-1
              Exit For
           End If
        End If
      Next i
      iStart=i
      Incr iCtr 'vbObj(0) Already Found
      'Print "vbObj(0).iBegin   = "vbObj(0).iBegin
      'Print "vbObj(0).iEnd     = "vbObj(0).iEnd
    
      'Find Beginning and End Of Other Object Properties
      iCtr=1
      For i=iStart To UBound(strArr,1)
        If Instr(strArr(i),"Begin ") Then
           If InStr(strArr(i),vbObj(iCtr).szObject) Then
              vbObj(iCtr).iBegin=i
           End If
           For j=i To UBound(strArr,1)
             If InStr(strArr(j),"End") Then
                vbObj(iCtr).iEnd=j-1
                Incr iCtr
                Exit For
             End If
           Next j
        End If
      Next i
    
      For i=0 To UBound(vbObj,1)
        vbObj(i).szName=strGetObjName(strArr(),vbObj(i).iBegin)
        iStart=vbObj(i).iBegin+1
        Select Case vbObj(i).szObject
          Case "VB.Form"
            If i=0 Then
               vbObj(0).szSdkControl=vbObj(0).szName
            End If
            For j=iStart To vbObj(i).iEnd
              If InStr(strArr(j),"Caption") Then
                 iPos=InStr(strArr(j),Chr$(34))
                 vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
              End If
              If InStr(strArr(j),"ScaleHeight") Then
                 vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
              End If
              If InStr(strArr(j),"ScaleWidth") Then
                 vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
              End If
              If InStr(strArr(j),"StartUpPosition") Then
                 vbObj(i).X=400
                 vbObj(i).Y=300
              End If
              vbObj(i).dwStyle=%WS_OVERLAPPEDWINDOW
              vbObj(i).dwExStyle=0
            Next j
          Case "VB.TextBox"
            For j=iStart To vbObj(i).iEnd
              If InStr(strArr(j),"Height") Then
                 vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
              End If
              If InStr(strArr(j),"Width") Then
                 vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
              End If
              If InStr(strArr(j),"Left") Then
                 vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
              End If
              If InStr(strArr(j),"Top") Then
                 vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
              End If
              vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE
              vbObj(i).dwExStyle=%WS_EX_CLIENTEDGE
            Next j
          Case "VB.CommandButton"
            For j=iStart To vbObj(i).iEnd
              If InStr(strArr(j),"Caption") Then
                 iPos=InStr(strArr(j),Chr$(34))
                 vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
              End If
              If InStr(strArr(j),"Height") Then
                 vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
              End If
              If InStr(strArr(j),"Width") Then
                 vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
              End If
              If InStr(strArr(j),"Left") Then
                 vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
              End If
              If InStr(strArr(j),"Top") Then
                 vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
              End If
              vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE Or %BS_NOTIFY
              vbObj(i).dwExStyle=0
            Next j
        End Select
        If i Then  'Form Equate By Concatenating Form Name (szObj(0)) To Control Name With Underscore In Middle
           vbObj(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
        Else       'Its the Main Form
           vbObj(i).szEquate="%" & vbObj(0).szName
        End If
      Next i
      'Print
      'Print " i vbObj(i).szObject    Sdk           Begin  End vbObj(i).szName      Ht   Wd   X    Y   Caption                              szEquate"
      'Print "======================================================================================================================================"
      'For i=0 To UBound(vbObj,1)
      '  Print i Tab(4) vbObj(i).szObject Tab(25) vbObj(i).szSdkControl Tab(40) vbObj(i).iBegin Tab(45) vbObj(i).iEnd _
      '  Tab(50) vbObj(i).szName Tab(70) vbObj(i).Height Tab(75) vbObj(i).Width Tab(80) vbObj(i).X Tab(85) vbObj(i).Y _
      '  Tab(90) vbObj(i).szCaption Tab(120) vbObj(i).szEquate
      'Next i
      'Print
      'Print "Leaving blnLoadObjProperties()"
      'Print
    
      blnLoadObjProperties=%TRUE
    End Function
    
    
    Function blnLoadVbObjs(strArr() As String, vbObj() As vbObject) As Long
      Register i As Long, j As Long
      Local blnFound As Long
      Local iCtr As Long
    
      For i=1 To UBound(strArr,1)
        If InStr(strArr(i),"Begin") Then
           blnFound=%FALSE
           For j=0 To UBound(g_strObjects,1)
             If InStr(strArr(i),g_strObjects(j)) Then
                blnFound=%True
                vbObj(iCtr).szObject=g_strObjects(j)
                vbObj(iCtr).szSdkControl=g_strSdkObjects(j)
                Incr iCtr
                Exit For
             End If
           Next j
           If blnFound=%FALSE Then
              Print "Unidentified VB Object!"
              blnLoadVbObjs=%FALSE
              Exit Function
           End If
        End If
      Next i
    
      blnLoadVbObjs=%TRUE
    End Function
    
    
    Function blnLoadVbProcs(strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure) As Long
      Register i As Long, j As Long
      Local iCtr As Long
    
      Print
      Print"Entering blnLoadVbProcs()"
      Print
      Print " iCtr  szType    vbProc(iCtr).szNewSymbol            iType  iBegin    iEnd   blnContainsObject blnContainsUnderscore  szObjectName   szEventName     szOriginalName"
      Print "==================================================================================================================================================================="
      For i=0 To Ubound(strArr,1)
        If Instr(strArr(i),"Private Sub") Then
           vbProc(iCtr).szType="Sub"
           vbProc(iCtr).iType=0
           vbProc(iCtr).iBegin=i                  'This is the line number where a Sub begins
           For j=i To UBound(strArr,1)            'Find out line number where Sub Ends
             If InStr(strArr(j),"End Sub") Then
                vbProc(iCtr).iEnd=j
                Exit For
             End If
           Next j
           For j=0 To UBound(vbObj,1)                  'Now find out if a control name stored in vbObj()
             If InStr(strArr(i),vbObj(j).szName) Then  'is in procedure name, i.e., cmdButton1
                vbProc(iCtr).blnContainsObject=%TRUE
                vbProc(iCtr).szObjectName=vbObj(j).szName
                vbProc(iCtr).szSdkObjectType=vbObj(j).szSdkControl
                Exit For
             End If
           Next j
           For j=i To UBound(strArr,1)            'Find out if procedure line contains underscore
             If InStr(strArr(j),"_") Then
                vbProc(iCtr).blnContainsUnderscore=%TRUE
                Exit For
             End If
           Next j
           For j=1 To UBound(g_strEventNames,1)
             If InStr(strArr(i),g_strEventNames(j)) Then
                vbProc(iCtr).blnContainsEventName=%TRUE
                vbProc(iCtr).szEventName=g_strEventNames(j)
                Exit For
             End If
           Next j
           If vbProc(iCtr).blnContainsObject Then
              If vbProc(iCtr).blnContainsUnderscore Then
                 If vbProc(iCtr).blnContainsEventName Then
                    vbProc(iCtr).blnEventProcedure=%TRUE
                 End If
              End If
           End If
           If vbProc(iCtr).blnEventProcedure Then
              vbProc(iCtr).szOriginalSymbol=vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
              vbProc(iCtr).szNewSymbol=vbObj(0).szName & "_" & vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
           End If
           Print iCtr Tab(8) vbProc(iCtr).szType Tab(18) vbProc(iCtr).szNewSymbol Tab(53) vbProc(iCtr).iType Tab(60) vbProc(iCtr).iBegin Tab(70) vbProc(iCtr).iEnd _
           Tab(77) vbProc(iCtr).blnContainsObject Tab(95) vbProc(iCtr).blnContainsUnderscore Tab(120) vbProc(iCtr).szObjectName _
           Tab(135) vbProc(iCtr).szEventName Tab(150) vbProc(iCtr).szOriginalSymbol
           Incr iCtr
        End If
        If InStr(strArr(i),"Public Sub") Then
           Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
           Incr iCtr
        End If
        If InStr(strArr(i),"Private Function") Then
           Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
           Incr iCtr
        End If
        If InStr(strArr(i),"Public Function") Then
           Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
           Incr iCtr
        End If
      Next i
    
      'Count Event Procedures For Each Object And Store In vbObj().  This Will Be Useful To Know Later.
      Print : Print
      For i=0 To UBound(vbObj,1)
        iCtr=0
        For j=0 To UBound(vbProc,1)
          If vbObj(i).szName=vbProc(j).szObjectName Then
             Incr iCtr
          End If
        Next j
        vbObj(i).iCountEvents=iCtr
      Next i
      Print " i            vbObj(i).szName      vbObj(i).iCountEvents"
      Print "========================================================"
      For i=0 To UBound(vbObj,1)
        Print i,vbObj(i).szName,,vbObj(i).iCountEvents
      Next i
      Print
      Print "Leaving blnLoadVbProcs()"
      Print
    
      blnLoadVbProcs=%TRUE
    End Function
    
    
    Function iCountVariables(strArr() As String) As Long
      Register i As Long
      Local iCtr As Long
    
      For i=0 To UBound(strArr,1)
        If InStr(strArr(i),"Dim") Then
           Incr iCtr
        End If
      Next i
    
      iCountVariables=iCtr
    End Function
    
    
    Sub LoadFormSymbolTable(strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure, vbSym() As vbSymbolTable)
      Local strTmp,strVarType As String
      Register i As Long, j As Long
    
      j=UBound(vbObj,1)
      Incr j
      For i=0 To UBound(strArr,1)
        If InStr(strArr(i),"Private Sub") Or InStr(strArr(i),"Private Function") Then
           Exit For
        End If
        If InStr(strArr(i),"Dim") Then               'You need to add functionality here to determine if its
           strTmp=Remove$(strArr(i),"Dim ")          'an array or a type/structure or not
           strVarType=strGetVariableType(strTmp)
           vbSym(j).szSpecificType=strVarType
           'vbSym(j).szSpecificType=
           vbSym(j).szSymbol=Left$(strTmp,Instr(strTmp," ")-1)
           vbSym(j).Scope=1
           'Print #fp,"strTmp="strTmp
           Incr j
        End If
      Next i
      For i=0 To UBound(vbProc,1)
        vbSym(j).szSymbol=vbProc(i).szOriginalSymbol
        vbSym(j).iGeneralType=3
        vbSym(j).szSpecificType=vbProc(i).szType
        Incr j
      Next i
      
    End Sub
    
    
    Function iIdentifyTerm(szTerm As Asciiz*256, vbSym() As vbSymbolTable, iGenType As Long, szSpecType As Asciiz*24, iSymbol As Long) As Long
      Register i As Long, j As Long
      
      Print 
      Print "Entering blnIdentifyTerm()"
      If Left$(szTerm,1)=Chr$(34) And Right$(szTerm,1)=Chr$(34) And Tally(szTerm,Chr$(34))=2 Then  'Its a simple string constant
         Print "It Looks A Lot Like A String Constant!"
         iIdentifyTerm=2                                   'We're obviously going to need to handle situations such as...
         Exit Function                                     '"His Last Name Is " & txtLastName.Text & " And He Lives At "
      End If   
      'We'll need code to recognize numeric constants!!!  But will get to that later!!!
      For i=0 To UBound(vbSym)                  'See if one of the symbols in the Symbol Table can be
        If Instr(szTerm,vbSym(i).szSymbol) Then 'found in the Term passed to this function.
           'blnFound=%TRUE
           Print "We Found Something!!!!!!"
           Print "We Found Something!!!!!!"
           iGenType=vbSym(i).iGeneralType
           szSpecType=vbSym(i).szSpecificType
           iIdentifyTerm=3
           iSymbol=i
           Exit Function
           Exit For
        End If   
      Next i
      Print "Leaving blnIdentifyTerm()"
      
      iIdentifyTerm=0
    End Function
    
    
    Function blnDoTextBoxCode(vbSym() As vbSymbolTable, iSymbol As Long, vbLn As vbCodeLine, strWorkBuffer() As String) As Long
      Local strObjectCall As String
      Register i As Long, j As Long
      
      'If you check the include file of this console app you'll see there a bunch of global arrays holding all sorts of
      'VB specific objects, properties, methods, and event names.  Of particular importance here is the global array
      'g_strTextBoxProps(), which I'll reproduce here...
      
      ''Initial string array to hold respective property names of global VB objects.  Below is TextBox
      'g_strTextBoxProps(1)="Height"
      'g_strTextBoxProps(2)="Left"
      'g_strTextBoxProps(3)="TabIndex"
      'g_strTextBoxProps(4)="Top"
      'g_strTextBoxProps(5)="Width"
      'g_strTextBoxProps(6)="Text"
      '
      'What we must now do is determine which object property/method call is being requested on behalf of the txtText1 object.
      'In procedural programming languages this will translate to a function call where the first parameter of the call will
      'probably be the left operand of the object.property pair.  We check to find if a '.' is in the string (it had better be!),
      'and we parse out the property name and find out (surprise!, Surprise!) it is 'Text'.  In the loop below we iterate through
      'all the property names in g_strTextBoxProps() and find indeed that a text box has a property named 'Text'.  So in that
      'code we finally piece together a Api function call where the first parameter is indeed the handle of the object whose
      'Text is being set.  It could just as well have been a DDT Dialog Set Text or whatever that syntax is.  Not exactly trivial!
      'However, I think what I have done here, while only capable really of translating this one ridiculously simple program, does
      'provide an extensible framework where hopefully all VB Object / PB Function Call translations can be made.   
      
      Print "Entering blnDoTextBoxCode()"
      Print "vbLn.vbAssignment.LeftTerm          = " vbLn.vbAssignment.LeftTerm.szTerm
      Print "vbLn.vbAssignment.LeftTermIdentity  = " vbLn.vbAssignment.LeftTermIdentity
      Print "vbLn.vbAssignment.RightTerm         = " vbLn.vbAssignment.RightTerm.szTerm
      Print "vbLn.vbAssignment.RightTermIdentity = " vbLn.vbAssignment.RightTermIdentity
      Select Case As Long vbLn.vbAssignment.LeftTermIdentity
        Case %vbObject
          Print "The Left Term Is An Object Of Type VB.TextBox"
        Case %Integer
          Print "The Left Term Is An Integer" 
      End Select 
      Select Case As Long vbLn.vbAssignment.RightTermIdentity
        Case %StringConstant
          Print "The Right Term Is A String Constant"
        Case %vbObject
          Print "The Right Term Is An Object Of Type VB.TextBox"
        Case %Integer
          Print "The Right Term Is An Integer" 
      End Select
      Print 
      If InStr(vbLn.vbAssignment.LeftTerm.szTerm,".") Then
         strObjectCall= _
         Right$(vbLn.vbAssignment.LeftTerm.szTerm,Len(vbLn.vbAssignment.LeftTerm.szTerm)-Instr(vbLn.vbAssignment.LeftTerm.szTerm,"."))
         Print "strObjectCall      = " strObjectCall
         Print "Len(strObjectCall) = " Len(strObjectCall)
         For i=1 To UBound(g_strTextBoxProps)
           If strObjectCall=g_strTextBoxProps(i) Then
              Select Case g_strTextBoxProps(i)
                Case "Height"
                 
                Case "Left"
                 
                Case "Text"
                  strWorkBuffer(j)= "  Call SetWindowText(GetDlgItem(Wea.hWnd," & Trim$(vbSym(iSymbol).szEquate) & ")," & _
                  vbLn.vbAssignment.RightTerm.szTerm & ")" 
              End Select 
              Exit For
           End If 
         Next i 
      Else 
         Print "Something's Badly Wrong!  I'm Outta Here!"
         Function=%FALSE
         Exit Function
      End If 
       
      Print "Leaving blnDoTextBoxCode()"
      
      Function=%TRUE
    End Function
    
    
    Function blnExamineLine(vbPrc As vbProcedure, vbSym() As vbSymbolTable, vbLn As vbCodeLine, strLine As String, strWorkBuffer() As String) As Long
      Local szSpecTypeReturn As Asciiz*24
      Local iVarReturn As Long
      Local iSymbol As Long
    
      Print
      Print "Entering blnExamineLine()"
      Print "strLine       = "strLine
      'Note it isn't September yet and this isn't quite a beta yet, so the code for converting anything other that this one
      'assignment statement isn't in place below in the Select Case.  However, what this procedure will first look at is the
      'type of code line passed to it from blnConvertProc().  In our case here its an assignment statement, so that is where
      'code starts running.  You can see right away the first thing blnExamineLine tries to do.  It knows it has an assignmnt
      'statement so it wants to parse out a left term and a right term.  Then, after having those two strings in its clutches,
      'it needs to figure out what each is.  In our case here the left string is txtText1.Text and the right string is "You 
      'clicked cmdButtonX or whatever".  Here is what's in the console output...
      '
      '         vbLn.vbAssignment.RightTerm.szTerm       = "You Clicked cmdButton2 (the middle button)!"
      '         Entering blnIdentifyTerm()
      '         It Looks A Lot Like A String Constant!
      '
      'Look at the call to the Function iIdentifyTerm() invoked by the Select Case statement.  The enum discussed back in
      'blnConvertProc() is once again used, and iIdentifyTerm() tells us that the term passed to it looks like a literal
      'string constant.  Then the LeftTerm is parsed out and that is passed also to iIdentifyTerm() to see if it can figure
      'out what it is.  Below is the console output from this call...
      '
      '         vbLn.vbAssignment.LeftTerm.szTerm=txtText1.Text
      '         Entering blnIdentifyTerm()
      '         We Found Something!!!!!!
      '         We Found Something!!!!!!
      '         Ascertained Identity of Left Term To Be vbObject txtText1.Text
      '         iVarReturn       =  2
      '         szSpecTypeReturn = VB.TextBox
      '
      'You'll want to look at iIdentifyTerm().  I won't discuss it in any detail, but it isn't really rocket science.  It
      'gets access to the SymbolTable, and is able to figure out what the object is.  Lets summarize where we are at this point.
      'We know that the code line we want to convert is an assignment statement in which a string constant is in some way
      'going to be assigned to some textbox property of txtText1. But we're not exactly sure of the relationship.  Don't jump
      'to the conclusion that the Text property is going to be set because we havn't yet looked at the object function that will
      'be called on behalf of the text box object.  For all we know, the literal string constant could be the name of a new
      'Font that is going to be assigned to the textbox.  It is to that issue we must now turn.  So below you'll see that
      'program execution eventually branches to blnDoTextBoxCode() after some preliminary tests.  So now lets jump with this
      'discussion to blnDoTextBoxCode()..... 
      Select Case vbLn.iType
        Case %Assignment
          vbLn.vbAssignment.RightTerm.szTerm=Right$(strLine,Len(strLine)-Instr(strLine,"="))
          vbLn.vbAssignment.RightTerm.szTerm=Trim$(vbLn.vbAssignment.RightTerm.szTerm)
          Print "vbLn.vbAssignment.RightTerm.szTerm       = "vbLn.vbAssignment.RightTerm.szTerm
          Select Case As Long iIdentifyTerm(vbLn.vbAssignment.RightTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol) 
            Case %iIdentify_Term_Error
               blnExamineLine=%FALSE
               Exit Function
            Case %NumericConstant
             
            Case %StringConstant
              vbLn.vbAssignment.RightTermIdentity=%StringConstant
          End Select
          vbLn.vbAssignment.LeftTerm.szTerm=Trim$(Left$(strLine,Instr(strLine,"=")-1))
          Print "vbLn.vbAssignment.LeftTerm.szTerm="vbLn.vbAssignment.LeftTerm.szTerm
          Select Case As Long iIdentifyTerm(vbLn.vbAssignment.LeftTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol)  
            Case %iIdentify_Term_Error
               blnExamineLine=%FALSE
               Exit Function
            Case %NumericConstant
             
            Case %StringConstant
              vbLn.vbAssignment.RightTermIdentity=%StringConstant
    
            Case %vbObject 
              vbLn.vbAssignment.LeftTermIdentity=%vbObject
              Print "Ascertained Identity of Left Term To Be vbObject " vbLn.vbAssignment.LeftTerm.szTerm
              Print "iVarReturn       = "iVarReturn
              Print "szSpecTypeReturn = "szSpecTypeReturn 
          End Select
          If vbLn.vbAssignment.LeftTermIdentity=%vbObject Or vbLn.vbAssignment.RightTermIdentity=%vbObject Then
             Select Case szSpecTypeReturn
               Case "VB.Form"
             
               Case "VB.CommandButton"
             
               Case "VB.TextBox"
                 If blnDoTextBoxCode(vbSym(),iSymbol,vbLn,strWorkBuffer()) Then
                    Print "Succeeded In Writing TextBox Code!"
                    Print strWorkBuffer(0)
                 Else
                    Print "Failed To Write TextBox Code!" 
                 End If  
               Case "VB.ListBox" 
           
          End Select 
          End If
          
        Case %vbStatement
         
        Case %vbBlockStatement
         
        Case %CallProcedure 
           
      End Select
      
      Print "Leaving blnExamineLine()"
      
      blnExamineLine=%TRUE
    End Function
    
    
    Function blnConvertProc(iProcNum As Long, iCtr As Long, strConvertedVBProc() As String, vbProc() As vbProcedure, vbSym() As vbSymbolTable) As Long
      Local strWorkBuffer() As String
      Register i As Long, j As Long
      Local vbLn As vbCodeLine
      Local iEndSub As Long
      Local iLastCodeLine As Long
      Local iFinish As Long
      Local iStart As Long
      Local iLineCtr As Long
      
      Print
      Print "Entering blnConvertProc()"
      iEndSub=iCtr-1
      iLastCodeLine=iEndSub-1
      Print "iProcNum                     = " iProcNum      'The procedure number in vbProc() we're working on now
      Print "iCtr                         = " iCtr          'One more than the number of lines written into strConvertedVBProc()
      Print "iLastCodeLine                = " iLastCodeLine
      Print "iEndSub                      = " iEndSub
      Print "vbProc(iProcNum).szNewSymbol = " vbProc(iProcNum).szNewSymbol
      If vbProc(iProcNum).blnEventProcedure Then
         Print
         strConvertedVBProc(0)="Sub " & vbProc(iProcNum).szNewSymbol & "(Wea As WndEventArgs)"  'This just converts the proc declaration to PB
         iLineCtr=1                                                                             'equivalent.  Note subscript 0.
         For i=1 To iLastCodeLine      'We'll iterate through all the code lines passed to us      
           Select Case Tally(strConvertedVBProc(i),"=")  'As previously discussed, the first thing that needs to be done is to figure out what
             Case 0                                      'in the devil the code line is.  At this point we don't know a thing about it other
               Print "No Occurances of '=' Sign"         'than that it is a string of characters.  If there are no equal signs in it at this
             Case 1                                      'early point of just writting trial apps we'll assume it isn't an assignment statement.
               Print "One Occurance of '=' Sign"         'If its got one equal sign in it we'll assume it is an assignment statement.
               vbLn.vbAssignment.iType=0
               'vbLn.iType=0  'Its an assignment statement!
             Case >1
               Print "Multiple Occurances of '=' Sign.  Will Have To Examine This Line In Greater Detail To See What The Deal Is"
               Print "It May, For Example, Be An Assignment Statement Involving A String Where There Is An '=' Sign Embedded In The"
               Print "String To Be Assigned To Something, For Example A Textbox."  
           End Select 
           'At this point we've determined what the code line is.  In our case here its an assignment statement.  Note that vbLn is a UNION of 
           'type vbCodeLine, which, if determined above we're dealing with an assignment statement, will be loaded with a TYPE vbAssignmentStatement
           'variable.  Note that vbAssignment.iType is an enumeration like so...
           
           ''Enumeration                  Union vbCodeLine.iType
           '%Assignment                   =  0
           '%vbStatement                  =  1
           '%vbBlockStatement             =  2
           '%CallProcedure                =  3
           
           'So that is what is going on with the term - vbLn.vbAssignment.iType = 0.  Next, we need to work ourselves a little bit closer to 
           'converting the line.  Lets dimension another string variable of some arbitrary size ( strWorkBuffer(10) ) and pass everything we
           'have so far to that function to learn more about the code line.  Further note that we are now in a procedure ( blnConvertProc() )
           'whose mission in life is to convert a whole procedure.  But within this procedure we are now in we are presently in a For Loop
           'calling another procedure to move us closer to converting a single line of VB code.  So the discussion now moves to blnExamineLine().
           Redim strWorkBuffer(10) As String  'Make it arbitrarily large because we don't know how many lines of PowerBASIC code it will take to convert a VB line.
           If blnExamineLine(vbProc(iProcNum), vbSym(), vbLn, strConvertedVBProc(i), strWorkBuffer()) Then
              j=0 
              Do While strWorkBuffer(j)<>""
                 strConvertedVBProc(iLineCtr)=strWorkBuffer(j)
                 Incr j : Incr iLineCtr
              Loop 
              Erase strWorkBuffer
           Else
              Print "blnExamineLine() Returned %FALSE"
              blnConvertProc=%FALSE
              Exit Function   
           End If     
         Next i
         Print iEndSub,strConvertedVBProc(iEndSub)
         Print
      End If 
      Print "Leaving blnConvertProc()"
      Print
      
      blnConvertProc=%TRUE
    End Function
    
    
    Function PBMain() As Long
      Local strConvertedVBProc() As String
      Local szFileToConvert As Asciiz*256
      Local vbSym() As vbSymbolTable
      Local vbProc() As vbProcedure
      Register i As Long, j As Long
      Local strArray() As String
      Local vbLine As vbCodeLine
      Local iSizeOfProc As Long 
      Local vbObj() As vbObject
      Local iFinish As Long
      Local strLn As String
      Local iRecCnt As Long
      Local iStart As Long
      Local iCtr As Long
      Local fp1 As Long
    
      Call Initializations()
      'Change this line to reflect where you have frmVBConvert on your computer, or just put it in the same dir as the program.
      'szFileToConvert="C:\Program Files\Microsoft Visual Studio\VB98\Projects\vbConvert\frmVBConvert.frm"
      szFileToConvert="frmVBConvert.frm"
      fp1=Freefile
      Open szFileToConvert For Input As #fp1
      FileScan #fp1, Records To iRecCnt
      Redim strArray(iRecCnt) As String
      Line Input #fp1, strArray() To iRecCnt
      Close #fp1
      For i=0 To iRecCnt
        Print strArray(i)
      Next i
      Print "Everything Above This Line Is Simply The Contents of the frmVBConvert.frm File Being Output To The Screen."
      Print "It s Stored in strArray(), Which Was Dimensioned To Hold Its Contents.  Everything Below Is What This Program"
      Print "Is Doing With strArray()."
      Print
    
      For i=1 To iRecCnt                      '  This block of code loads vbObj() with objects found in *.frm file
        If InStr(strArray(i),"Begin ") Then   '  "Begin " seems to be how all objects are started in the *.frm file
           Incr iCtr                          '  so we can find out how many there are this ay.
        End If
      Next i
      Decr iCtr
      Redim vbObj(iCtr) As vbObject
      If blnLoadVbObjs(strArray(),vbObj()) Then     'This proc loads the just dimensioned vbObj() array with
         Print "blnLoadVbObjs() Succeeded!"         'info on the vb objects found in frmVBConvert.frm.  Note
      End If                                        'we're storing the file in strArray().
      Print : Print
      For i=0 To UBound(vbObj,1)
        Print i,vbObj(i).szObject
      Next i
      Print
      If blnLoadObjProperties(strArray(),vbObj()) Then      'This proc gets the rest of the info into vbObj()
         Print "blnLoadObjProperties() Succeeded!"          'for example converting twips to pixels and so on
      End If                                                'Lot of stuff set in the properties pane in VB IDE
      Print : Print
      Print " i  vbObj(i).szObject        vbObj(i).szName     vbObj(i).szSdkControl   vbObj(i).szEquate"     'Just display
      Print "=========================================================================================="     'what we got so far
      For i=0 To Ubound(vbObj)
        Print i Tab(5) vbObj(i).szObject Tab(30) vbObj(i).szName Tab(50) vbObj(i).szSdkControl Tab(74) vbObj(i).szEquate
      Next i
    
      'Find out how many procedures are in *.frm file      'Now lets start working on the procedures.  In this little
      iCtr=0                                               'VB program there are only three of them
      For i=0 To UBound(strArray,1)
        If InStr(strArray(i),"End Sub") Or InStr(strArray(i),"End Function") Then
           Incr iCtr
        End If
      Next i
      Print
      Print "There Are "iCtr" Procedures In The File."
      Decr iCtr
      Redim vbProc(iCtr) As vbProcedure
      If blnLoadVbProcs(strArray(),vbObj(),vbProc()) Then
         Print "blnLoadVbProcs() Succeeded!"
      Else
         Erase strArray,vbObj,vbProc
         Exit Function
      End If
      Print : Print
      Print " i   szType    iType  iBegin iEnd blnContainsObject blnContainsUnderscore szObjectName  szEventName   szOriginalSymbol         szNewSymbol"
      Print "=============================================================================================================================================================="
      For i=0 To UBound(vbProc)
        Print i Tab(6) vbProc(i).szType Tab(15) vbProc(i).iType Tab(22) vbProc(i).iBegin Tab(29) vbProc(i).iEnd Tab(34) vbProc(i).blnContainsObject _
        Tab(52) vbProc(i).blnContainsUnderscore Tab(75) vbProc(i).szObjectName Tab(89) vbProc(i).szEventName Tab(103) vbProc(i).szOriginalSymbol Tab(128) vbProc(i).szNewSymbol
      Next i
      Print
    
      'Find variables and fill symbol table
      iCtr=iCountVariables(strArray())  'at this point can't have multiple variables on one line       'Now things are starting to get interesting!  It looks like
      Print "iCountVariables="iCtr                                                                     'the concept of a 'symbol table' is something we're going to
      Redim vbSym(iCtr+UBound(vbObj,1)+UBound(vbProc,1)+1)                                             'need.
      Print "Ubound(vbSym,1) = "Ubound(vbSym,1)
      Print
      For i=0 To UBound(vbObj,1)
        vbSym(i).szSymbol=vbObj(i).szName            'e.g., txtFirstName, iCtr, strLastName, etc.
        vbSym(i).iGeneralType=2
        vbSym(i).szSpecificType=vbObj(i).szObject    'Object
        vbSym(i).szSdkType=vbObj(i).szSdkControl     'edit, button, static, listbox, etc.
        vbSym(i).Scope=2
        If i Then
           vbSym(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
        Else
           vbSym(i).szEquate="%" & vbObj(0).szName
        End If     
      Next i
      Call LoadFormSymbolTable(strArray(),vbObj(),vbProc(),vbSym()) 'only used i believe if form variables are in the frm file.  here there aren't any
      Print
      Print " i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope  vbSym(i).szEquate"
      Print "====================================================================================================================================="
      For i=0 To UBound(vbSym,1)
        Print i Tab(9)vbSym(i).szSymbol Tab(30)vbSym(i).iGeneralType Tab(55) vbSym(i).szSpecificType Tab(80) vbSym(i).szSdkType _
        Tab(100) vbSym(i).Scope Tab(115) vbSym(i).szEquate
      Next i
      Print
      
      'The below code will iterate through the three event procedures in vbProc().  It won't modify strArray() in any way, but will
      'dynamically dimension a new string array strConvertedVBProc() with four times the number of lines in the original proc.  This 
      'is just an arbitrary number and is based on the idea that the converted procedure may contain more lines than the original.
      'Finally, blnConvertProc() is called to convert the procedure.  A lot of data is passed to blnConvertProc(), as you can see.
      'Essentially, all the data gleaned so far by examining the whole of the frm file with a fine tooth comb.  The symbol table will
      'be passed, the vbProc() array, the code lines of the proc, as well as the index within vbProc() of the Proc being converted.
      'When blnConvertProc() returns strConvertedVBProc() will contain the new code lines - not the lines of VB code passed in.  A 
      'whole string of further procedures are called in blnConvertProc(), and it is to there you should next look.
      
      For i=0 To UBound(vbProc)                             'Loop through vbProc() array
        iSizeOfProc=vbProc(i).iEnd - vbProc(i).iBegin       'How many lines?  ( this info is in vbProc() )
        Redim strConvertedVBProc(iSizeOfProc*4) As String   'Make sure it is way big enough.  The original procedure will be read into this and
        iCtr=0                                              'and passed to blnConvertProc().  Within that procedure the lines will be converted
        For j=vbProc(i).iBegin To vbProc(i).iEnd            'and more than likely moved around some from the original.  strConvertedVBProc() is
          strConvertedVBProc(iCtr)=strArray(j)              'loaded here with original lines of the procedure held in strArray(), then this new
          Incr iCtr 'at least 3 lines unless empty proc     'string array is passed to blnConvertProc().
        Next j 
        If blnConvertProc(i,iCtr,strConvertedVBProc(),vbProc(),vbSym()) Then
           Print "blnConvertProc() Returned %TRUE"
           Print: Print
           j=0
           Do While strConvertedVBProc(j)<>""
              Print j, strConvertedVBProc(j)
              Incr j
           Loop 
           Print : Print
        Else
           Print "blnConvertProc() Returned %FALSE"
        End If 
        Print : Print : Print : Print
        Erase strConvertedVBProc
      Next i 
      Erase strArray, vbObj, vbProc, vbSym
      Waitkey$
    
      PBMain=0
    End Function
    Jeeze! I don't want to forget the include file needed by the above. Here it is...

    Code:
    'CCParse.inc
    %LOGPIXELSX                   =   88&
    %LOGPIXELSY                   =   90&
    %HWND_DESKTOP                 =   0
    %FALSE                        =   0
    %TRUE                         =   1
    
    ' Window Styles
    %WS_OVERLAPPED      = &H0
    %WS_POPUP           = &H80000000
    %WS_CHILD           = &H40000000
    %WS_MINIMIZE        = &H20000000
    %WS_VISIBLE         = &H10000000
    %WS_DISABLED        = &H08000000
    %WS_CLIPSIBLINGS    = &H04000000
    %WS_CLIPCHILDREN    = &H02000000
    %WS_MAXIMIZE        = &H01000000
    %WS_CAPTION         = &H00C00000  ' WS_BORDER OR WS_DLGFRAME
    %WS_BORDER          = &H00800000
    %WS_DLGFRAME        = &H00400000
    %WS_VSCROLL         = &H00200000
    %WS_HSCROLL         = &H00100000
    %WS_SYSMENU         = &H00080000
    %WS_THICKFRAME      = &H00040000
    %WS_GROUP           = &H00020000
    %WS_TABSTOP         = &H00010000
    %WS_MINIMIZEBOX     = &H00020000
    %WS_MAXIMIZEBOX     = &H00010000
    %WS_TILED           = %WS_OVERLAPPED
    %WS_ICONIC          = %WS_MINIMIZE
    %WS_SIZEBOX         = %WS_THICKFRAME
    %WS_OVERLAPPEDWIN   = %WS_OVERLAPPED OR %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME
    %WS_OVERLAPPEDWINDOW= %WS_OVERLAPPED OR %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX
    %WS_EX_CLIENTEDGE   = &H00000200
    
    ' Button Control Styles
    %BS_TEXT            = &H0&
    %BS_PUSHBUTTON      = &H0&
    %BS_DEFPUSHBUTTON   = &H1&
    %BS_DEFAULT         = %BS_DEFPUSHBUTTON
    %BS_CHECKBOX        = &H2&
    %BS_AUTOCHECKBOX    = &H3&
    %BS_RADIOBUTTON     = &H4&
    %BS_3STATE          = &H5&
    %BS_AUTO3STATE      = &H6&
    %BS_GROUPBOX        = &H7&
    %BS_USERBUTTON      = &H8&
    %BS_AUTORADIOBUTTON = &H9&
    %BS_OWNERDRAW       = &HB&
    %BS_LEFTTEXT        = &H20&
    %BS_ICON            = &H40&
    %BS_BITMAP          = &H80&
    %BS_LEFT            = &H100&
    %BS_RIGHT           = &H200&
    %BS_CENTER          = &H300&
    %BS_TOP             = &H400&
    %BS_BOTTOM          = &H800&
    %BS_VCENTER         = &HC00&
    %BS_PUSHLIKE        = &H00001000&
    %BS_MULTILINE       = &H00002000&
    %BS_NOTIFY          = &H00004000&
    %BS_FLAT            = &H00008000&
    %BS_RIGHTBUTTON     = %BS_LEFTTEXT
    
    DECLARE FUNCTION GetDC LIB "USER32.DLL" ALIAS "GetDC" (BYVAL hWnd AS DWORD) AS DWORD
    DECLARE FUNCTION GetDeviceCaps LIB "GDI32.DLL" ALIAS "GetDeviceCaps" (BYVAL hdc AS DWORD, BYVAL nIndex AS LONG) AS LONG
    DECLARE FUNCTION ReleaseDC LIB "USER32.DLL" ALIAS "ReleaseDC" (BYVAL hWnd AS DWORD, BYVAL hDC AS DWORD) AS LONG
    
    Global g_strObjects()         As String      'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
    Global g_strSdkObjects()      As String      'Corresponding Sdk name for a control, i.e., 'edit"
    Global g_strFormProps()       As String      'Caption, StartUpPosition, etc
    Global g_strTextBoxProps()    As String
    Global g_strCmdButtonProps()  As String
    Global g_strEventNames()      As String
    Global g_strButtonMessages()  As String
    
    Sub Initializations()
      Redim g_strObjects(2)         As String  'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
      Redim g_strSdkObjects(2)      As String  'Corresponding Sdk name for a control, i.e., 'edit"
      Redim g_strFormProps(9)       As String  'Caption, StartUpPosition, etc
      Redim g_strTextBoxProps(6)    As String  'MultiLine, scroll bars, etc.
      Redim g_strCmdButtonProps(6)  As String  'Visible, Height, etc.
      Redim g_strEventNames(7)      As String  'Event names encountered in actual procedures, e.g., cmdButton_Click().  'Click' would be event name
      Redim g_strButtonMessages(8)  As String  'strName of button message, i.e., what is in the Hiwrd(wParam) - notification messages
    
      'Initialize string array to hold names of global VB Objects as in *.frm file, i.e., Forms, Command Buttons, Text Boxes, etc
      g_strObjects(0)="VB.Form"
      g_strObjects(1)="VB.TextBox"            :  g_strSdkObjects(1)="edit"
      g_strObjects(2)="VB.CommandButton"      :  g_strSdkObjects(2)="button"
    
      'Initial string array to hold respective property names of global VB objects.  Below is Form
      g_strFormProps(1)="Caption"
      g_strFormProps(2)="ClientHeight"
      g_strFormProps(3)="ClientLeft"
      g_strFormProps(4)="ClientTop"
      g_strFormProps(5)="ClientWidth"
      g_strFormProps(6)="LinkTopic"
      g_strFormProps(7)="ScaleHeight"
      g_strFormProps(8)="ScaleWidth"
      g_strFormProps(9)="StartUpPosition"
    
      'Initial string array to hold respective property names of global VB objects.  Below is TextBox
      g_strTextBoxProps(1)="Height"
      g_strTextBoxProps(2)="Left"
      g_strTextBoxProps(3)="TabIndex"
      g_strTextBoxProps(4)="Top"
      g_strTextBoxProps(5)="Width"
      g_strTextBoxProps(6)="Text"
    
      'Initial string array to hold respective property names of global VB objects.  Below is Push Button
      g_strCmdButtonProps(1)="Caption"
      g_strCmdButtonProps(2)="Height"
      g_strCmdButtonProps(3)="Left"
      g_strCmdButtonProps(4)="TabIndex"
      g_strCmdButtonProps(5)="Top"
      g_strCmdButtonProps(6)="Width"
    
      'Load A Few VB Event Names
      g_strEventNames(1)="Load"
      g_strEventNames(2)="Click"
      g_strEventNames(3)="GotFocus"
      g_strEventNames(4)="KeyDown"
      g_strEventNames(5)="KeyPress"
      g_strEventNames(6)="Change"
      g_strEventNames(7)="Validate"
    
      g_strButtonMessages(1)="BN_CLICKED"     'I don't think I even used any of these!!!
      g_strButtonMessages(2)="BN_DBLCLK"      '
      g_strButtonMessages(3)="BN_DISABLE"     '
      g_strButtonMessages(4)="BN_PUSHED"
      g_strButtonMessages(5)="BN_KILLFOCUS"
      g_strButtonMessages(6)="BN_PAINT"
      g_strButtonMessages(7)="BN_SETFOCUS"
      g_strButtonMessages(8)="BN_UNPUSHED"
    End Sub
    Note that if you want to take the time to figure it out the trail of comments starts down in PBMain() then moves up through the translation procedures as they are called.
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

  • #2
    Output

    Below is the output from running the above program, copied from the console output...

    Code:
    'VERSION 5.00
    'Begin VB.Form frmVBConvert
    '   Caption         =   "This Is A Visual Basic Form"
    '   ClientHeight    =   3195
    '   ClientLeft      =   60
    '   ClientTop       =   345
    '   ClientWidth     =   4680
    '   LinkTopic       =   "Form1"
    '   ScaleHeight     =   3195
    '   ScaleWidth      =   4680
    '   StartUpPosition =   2  'CenterScreen
    '   Begin VB.TextBox txtText1
    '      Height          =   435
    '      Left            =   630
    '      TabIndex        =   3
    '      Top             =   2160
    '      Width           =   3285
    '   End
    '   Begin VB.CommandButton cmdButton3
    '      Caption         =   "cmdButton3"
    '      Height          =   495
    '      Left            =   1440
    '      TabIndex        =   2
    '      Top             =   1470
    '      Width           =   1695
    '   End
    '   Begin VB.CommandButton cmdButton2
    '      Caption         =   "cmdButton2"
    '      Height          =   495
    '      Left            =   1440
    '      TabIndex        =   1
    '      Top             =   840
    '      Width           =   1695
    '   End
    '   Begin VB.CommandButton cmdButton1
    '      Caption         =   "cmdButton1"
    '      Height          =   495
    '      Left            =   1440
    '      TabIndex        =   0
    '      Top             =   210
    '      Width           =   1695
    '   End
    'End
    'Attribute VB_Name = "frmVBConvert"
    'Attribute VB_GlobalNameSpace = False
    'Attribute VB_Creatable = False
    'Attribute VB_PredeclaredId = True
    'Attribute VB_Exposed = False
    'Private Sub cmdButton1_Click()
    '  txtText1.Text = "You Clicked cmdButton1 (the top button)!"
    'End Sub
    
    'Private Sub cmdButton2_Click()
    '  txtText1.Text = "You Clicked cmdButton2 (the middle button)!"
    'End Sub
    
    'Private Sub cmdButton3_Click()
    '  txtText1.Text = "You Clicked cmdButton3 (the bottom button)!"
    'End Sub
    
    'Everything Above This Line Is Simply The Contents of the frmVBConvert.frm File Being Output To The Screen.
    'It s Stored in strArray(), Which Was Dimensioned To Hold Its Contents.  Everything Below Is What This Program
    'Is Doing With strArray().
    
    'blnLoadVbObjs() Succeeded!
    
    
    ' 0            VB.Form
    ' 1            VB.TextBox
    ' 2            VB.CommandButton
    ' 3            VB.CommandButton
    ' 4            VB.CommandButton
    
    'blnLoadObjProperties() Succeeded!
    
    
    ' i  vbObj(i).szObject        vbObj(i).szName     vbObj(i).szSdkControl   vbObj(i).szEquate
    '==========================================================================================
    ' 0  VB.Form                  frmVBConvert        frmVBConvert            %frmVBConvert
    ' 1  VB.TextBox               txtText1            edit                    %frmVBConvert_txtText1
    ' 2  VB.CommandButton         cmdButton3          button                  %frmVBConvert_cmdButton3
    ' 3  VB.CommandButton         cmdButton2          button                  %frmVBConvert_cmdButton2
    ' 4  VB.CommandButton         cmdButton1          button                  %frmVBConvert_cmdButton1
    
    'There Are  3  Procedures In The File.
    
    'Entering blnLoadVbProcs()
    
    ' iCtr  szType    vbProc(iCtr).szNewSymbol            iType  iBegin    iEnd   blnContainsObject blnContainsUnderscore  szObjectName   szEventName     szOriginalName
    '===================================================================================================================================================================
    ' 0     Sub       frmVBConvert_cmdButton1_Click       0      48        50     1                 1                       cmdButton1     Click          cmdButton1_Click
    ' 1     Sub       frmVBConvert_cmdButton2_Click       0      52        54     1                 1                       cmdButton2     Click          cmdButton2_Click
    ' 2     Sub       frmVBConvert_cmdButton3_Click       0      56        58     1                 1                       cmdButton3     Click          cmdButton3_Click
    
    
    ' i            vbObj(i).szName      vbObj(i).iCountEvents
    '========================================================
    ' 0            frmVBConvert                 0
    ' 1            txtText1                     0
    ' 2            cmdButton3                   1
    ' 3            cmdButton2                   1
    ' 4            cmdButton1                   1
    
    'Leaving blnLoadVbProcs()
    
    'blnLoadVbProcs() Succeeded!
    
    
    ' i   szType    iType  iBegin iEnd blnContainsObject blnContainsUnderscore szObjectName  szEventName   szOriginalSymbol         szNewSymbol
    '==============================================================================================================================================================
    ' 0   Sub       0      48     50   1                 1                     cmdButton1    Click         cmdButton1_Click         frmVBConvert_cmdButton1_Click
    ' 1   Sub       0      52     54   1                 1                     cmdButton2    Click         cmdButton2_Click         frmVBConvert_cmdButton2_Click
    ' 2   Sub       0      56     58   1                 1                     cmdButton3    Click         cmdButton3_Click         frmVBConvert_cmdButton3_Click
    
    'iCountVariables= 0
    'Ubound(vbSym,1) =  7
    
    
    ' i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope  vbSym(i).szEquate
    '=====================================================================================================================================
    ' 0      frmVBConvert          2                       VB.Form                  frmVBConvert         2             %frmVBConvert
    ' 1      txtText1              2                       VB.TextBox               edit                 2             %frmVBConvert_txtText1
    ' 2      cmdButton3            2                       VB.CommandButton         button               2             %frmVBConvert_cmdButton3
    ' 3      cmdButton2            2                       VB.CommandButton         button               2             %frmVBConvert_cmdButton2
    ' 4      cmdButton1            2                       VB.CommandButton         button               2             %frmVBConvert_cmdButton1
    ' 5      cmdButton1_Click      3                       Sub                                           0
    ' 6      cmdButton2_Click      3                       Sub                                           0
    ' 7      cmdButton3_Click      3                       Sub                                           0
    
    
    'Entering blnConvertProc()
    'iProcNum                     =  0
    'iCtr                         =  3
    'iLastCodeLine                =  1
    'iEndSub                      =  2
    'vbProc(iProcNum).szNewSymbol = frmVBConvert_cmdButton1_Click
    
    'One Occurance of '=' Sign
    
    'Entering blnExamineLine()
    'strLine       =   txtText1.Text = "You Clicked cmdButton1 (the top button)!"
    'vbLn.vbAssignment.RightTerm.szTerm       = "You Clicked cmdButton1 (the top button)!"
    
    'Entering blnIdentifyTerm()
    'It Looks A Lot Like A String Constant!
    'vbLn.vbAssignment.LeftTerm.szTerm=txtText1.Text
    
    'Entering blnIdentifyTerm()
    'We Found Something!!!!!!
    'We Found Something!!!!!!
    'Ascertained Identity of Left Term To Be vbObject txtText1.Text
    'iVarReturn       =  2
    'szSpecTypeReturn = VB.TextBox
    'Entering blnDoTextBoxCode()
    'vbLn.vbAssignment.LeftTerm          = txtText1.Text
    'vbLn.vbAssignment.LeftTermIdentity  =  3
    'vbLn.vbAssignment.RightTerm         = "You Clicked cmdButton1 (the top button)!"
    'vbLn.vbAssignment.RightTermIdentity =  2
    'The Left Term Is An Object Of Type VB.TextBox
    'The Right Term Is A String Constant
    
    'strObjectCall      = Text
    'Len(strObjectCall) =  4
    'Leaving blnDoTextBoxCode()
    'Succeeded In Writing TextBox Code!
    '  Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton1 (the top button)!")
    'Leaving blnExamineLine()
    ' 2            End Sub
    
    'Leaving blnConvertProc()
    
    'blnConvertProc() Returned %TRUE
    
    
    ' 0            Private Sub frmVBConvert_cmdButton1_Click(Wea As WndEventArgs)
    ' 1              Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton1 (the top button)!")
    ' 2            End Sub
    
    
    
    
    
    
    
    'Entering blnConvertProc()
    'iProcNum                     =  1
    'iCtr                         =  3
    'iLastCodeLine                =  1
    'iEndSub                      =  2
    'vbProc(iProcNum).szNewSymbol = frmVBConvert_cmdButton2_Click
    
    'One Occurance of '=' Sign
    
    'Entering blnExamineLine()
    'strLine       =   txtText1.Text = "You Clicked cmdButton2 (the middle button)!"
    'vbLn.vbAssignment.RightTerm.szTerm       = "You Clicked cmdButton2 (the middle button)!"
    
    'Entering blnIdentifyTerm()
    'It Looks A Lot Like A String Constant!
    'vbLn.vbAssignment.LeftTerm.szTerm=txtText1.Text
    
    'Entering blnIdentifyTerm()
    'We Found Something!!!!!!
    'We Found Something!!!!!!
    'Ascertained Identity of Left Term To Be vbObject txtText1.Text
    'iVarReturn       =  2
    'szSpecTypeReturn = VB.TextBox
    'Entering blnDoTextBoxCode()
    'vbLn.vbAssignment.LeftTerm          = txtText1.Text
    'vbLn.vbAssignment.LeftTermIdentity  =  3
    'vbLn.vbAssignment.RightTerm         = "You Clicked cmdButton2 (the middle button)!"
    'vbLn.vbAssignment.RightTermIdentity =  2
    'The Left Term Is An Object Of Type VB.TextBox
    'The Right Term Is A String Constant
    
    'strObjectCall      = Text
    'Len(strObjectCall) =  4
    'Leaving blnDoTextBoxCode()
    'Succeeded In Writing TextBox Code!
    '  Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton2 (the middle button)!")
    'Leaving blnExamineLine()
    ' 2            End Sub
    
    'Leaving blnConvertProc()
    
    'blnConvertProc() Returned %TRUE
    
    
    ' 0            Private Sub frmVBConvert_cmdButton2_Click(Wea As WndEventArgs)
    ' 1              Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton2 (the middle button)!")
    ' 2            End Sub
    
    
    
    
    
    
    
    'Entering blnConvertProc()
    'iProcNum                     =  2
    'iCtr                         =  3
    'iLastCodeLine                =  1
    'iEndSub                      =  2
    'vbProc(iProcNum).szNewSymbol = frmVBConvert_cmdButton3_Click
    
    'One Occurance of '=' Sign
    
    'Entering blnExamineLine()
    'strLine       =   txtText1.Text = "You Clicked cmdButton3 (the bottom button)!"
    'vbLn.vbAssignment.RightTerm.szTerm       = "You Clicked cmdButton3 (the bottom button)!"
    
    'Entering blnIdentifyTerm()
    'It Looks A Lot Like A String Constant!
    'vbLn.vbAssignment.LeftTerm.szTerm=txtText1.Text
    
    'Entering blnIdentifyTerm()
    'We Found Something!!!!!!
    'We Found Something!!!!!!
    'Ascertained Identity of Left Term To Be vbObject txtText1.Text
    'iVarReturn       =  2
    'szSpecTypeReturn = VB.TextBox
    'Entering blnDoTextBoxCode()
    'vbLn.vbAssignment.LeftTerm          = txtText1.Text
    'vbLn.vbAssignment.LeftTermIdentity  =  3
    'vbLn.vbAssignment.RightTerm         = "You Clicked cmdButton3 (the bottom button)!"
    'vbLn.vbAssignment.RightTermIdentity =  2
    'The Left Term Is An Object Of Type VB.TextBox
    'The Right Term Is A String Constant
    
    'strObjectCall      = Text
    'Len(strObjectCall) =  4
    'Leaving blnDoTextBoxCode()
    'Succeeded In Writing TextBox Code!
    '  Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton3 (the bottom button)!")
    'Leaving blnExamineLine()
    ' 2            End Sub
    
    'Leaving blnConvertProc()
    
    'blnConvertProc() Returned %TRUE
    
    
    ' 0            Private Sub frmVBConvert_cmdButton3_Click(Wea As WndEventArgs)
    ' 1              Call SetWindowText(GetDlgItem(Wea.hWnd,%frmVBConvert_txtText1),"You Clicked cmdButton3 (the bottom button)!")
    ' 2            End Sub
    Oh!, those Private Subs were changed to just Subs
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

    Comment


    • #3
      Converts Fully Actual Program, Code Lines And All

      After finally seeing my solution worked, I incorporated the added functionality of actually translating the OOP statements to PB code into the program 'proof of concept' app I posted last week. Here is that program again with the added code. What I have changed is that when the Open File Dialog Comes up it just displays *.frm files, and you want to click on frmVBConvert.frm.

      Also, it opens two output files instead of one. It opens an Output.txt that it writes debug info to, and the PowerBASIC program that should run is written to PBSource.bas. It should run.

      Code:
      #Compile Exe
      #Include "Win32api.inc"
      #Include "Comdlg32.inc"
      
      %LOGPIXELSX                   =   88&
      %LOGPIXELSY                   =   90&
      %BTN_LOAD_VB_PROJECT          = 1500&
      %BTN_CONVERT_VB_PROJECT       = 1505&
      %TXT_VB_PROJECT               = 1510&
      
      'Enumeration
      %SCALER_VARIABLE              = 0    'vbSymbolTable.iGeneralType
      %COMPLEX_VARIABLE             = 1
      %OBJECT_VARIABLE              = 2
      %PROCEDURE                    = 3
      
      'Enumeration
      %Assignment                   =  0   'Union vbCodeLine.iType
      %vbStatement                  =  1
      %vbBlockStatement             =  2
      %CallProcedure                =  3
      
      'Enumeration
      %iIdentify_Term_Error         =  0   '(for iIdentifyTerm() Function
      %NumericConstant              =  1   'and vbAssignmentStatement.LeftTermIdentity
      %StringConstant               =  2   'and vbAssignmentStatement.RightTermIdentity
      %vbObject                     =  3
      %Integer                      =  4
      %Long                         =  5
      %Single                       =  6
      %Double                       =  7
      %Currency                     =  8
      %Variant                      =  9
      
      Type WndEventArgs
        wParam                      As Long
        lParam                      As Long
        hWnd                        As Dword
        hInst                       As Dword
      End Type
      
      Type vbObject
        szObject                    As Asciiz*24
        szName                      As Asciiz*32
        szCaption                   As Asciiz*64
        szSdkControl                As Asciiz*16
        szEquate                    As Asciiz*32
        iBegin                      As Long
        iEnd                        As Long
        Width                       As Long
        Height                      As Long
        X                           As Long
        Y                           As Long
        TabIndex                    As Long
        iCountEvents                As Long
        dwExStyle                   As Dword
        dwStyle                     As Dword
      End Type
      
      Type vbProcedure
        szType                      As Asciiz*16   'Can be Sub or Function
        iType                       As Long        '0=Sub / 1=Function
        iBegin                      As Long        'What line in frm file?
        iEnd                        As Long        'Line # of End Sub or End Function
        blnContainsObject           As Long        '%TRUE / %FALSE Does the string contain a control in the *.frm file
        blnContainsUnderscore       As Long        'Is there an underscore in the name?
        blnContainsEventName        As Long        'Event name found in string?
        szObjectName                As Asciiz*16   'Name of control if event procedure for control
        szSdkObjectType             As Asciiz*16   'button, edit, static, listbox, etc
        szEventName                 As Asciiz*16   'Click, Keypress, Change, etc
        szOriginalSymbol            As Asciiz*64
        szNewSymbol                 As Asciiz*64
        blnRequiresWMCommand        As Long        'Will this procedure be routed from WM_COMMAND message?
        blnEventProcedure           As Long        'Using the above gleaned info, is it an Event Procedure (%TRUE / %FALSE)?
      End Type
      
      Type vbSymbolTable
        szSymbol                    As Asciiz*64   'e.g, txtFirstName, iNumber, strDate, etc.
        iGeneralType                As Long        'enumeration, i.e., simple scaler variable=0, complex variable=1, object variable=2, procedure=3
        szSpecificType              As Asciiz*24   '"TextBox", "CommonDialog", "Database", "Integer", "String", "Variant", "Sub", "Function", etc.
        blnArray                    As Long        'TRUE/FALSE. Could be an array of almost anything, e.g., textboxes, databases, integers, blnSymbolTables, whatever.
        szSdkType                   As Asciiz*16   'edit,button, etc.
        Scope                       As Long        '0=Local, 1=Form, 2=Public, 3=Static
        szEquate                    As Asciiz*64   'Put equate here if its an object
      End Type
      
      Type Term
        szTerm As Asciiz*256                    '256
      End Type
      
      Type vbAssignmentStatement
        iType                        As Long
        LeftTerm                     As Term    '256
        RightTerm                    As Term    '256
        LeftTermIdentity             As Long    '  4  1=%NumericConstant, 2=%StringConstant, 3=vbObject, 4=%Integer, 5=%Long, 6=%Single, 7=%Double, etc
        RightTermIdentity            As Long    '  4  ditto
      End Type
      
      Type vbStatement
        iType                        As Long
        szReservedWord               As Asciiz*16             '16
        szArguements                 As Asciiz*48             '48
      End Type
      
      Type vbBlockStatement
        iType                        As Long
        szStatement                  As Asciiz*32
      End Type
      
      Union vbCodeLine
        iType                        As Long
        vbAssignment                 As vbAssignmentStatement
        vbVerb                       As vbStatement
        vbBlock                      As vbBlockStatement
      End Union
      
      Type MessageHandler
        wMessage                    As Long        'e.g., %WM_CREATE, %WM_CLOSE
        dwFnPtr                     As Dword       'Address of function that handles wMessage
      End Type
      
      Declare Function FnPtr(wea As WndEventArgs) As Long   'procedure with same signature as message/event handlers
      
      Global MsgHdlr() As MessageHandler
      Global g_strObjects()         As String      'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
      Global g_strSdkObjects()      As String      'Corresponding Sdk name for a control, i.e., 'edit"
      Global g_strFormProps()       As String      'Caption, StartUpPosition, etc
      Global g_strTextBoxProps()    As String
      Global g_strCmdButtonProps()  As String
      Global g_strEventNames()      As String
      Global g_strButtonMessages()  As String
      
      Function TwipsPerPixelX() As Single
        Dim lngDC As Long
      
        lngDC = GetDC(%HWND_DESKTOP)
        TwipsPerPixelX=1440&/GetDeviceCaps(lngDC,%LOGPIXELSX)
        Call ReleaseDC(%HWND_DESKTOP,lngDC)
      End Function
      
      
      Function TwipsPerPixelY() As Single     'blasted vb dimensions
        Dim lngDC As Long                     'are in Twips!!!!!!!!!
      
        lngDC=GetDC(%HWND_DESKTOP)
        TwipsPerPixelY=1440&/GetDeviceCaps(lngDC,%LOGPIXELSY)
        Call ReleaseDC(%HWND_DESKTOP,lngDC)
      End Function
      
      
      Function fnWndProc_OnCreate(wea As WndEventArgs) As Long
        Local pCreateStruct As CREATESTRUCT Ptr
        Local hCtrl As Dword
      
        pCreateStruct=wea.lParam
        [email protected]
        Redim g_strObjects(2)         As String  'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
        Redim g_strSdkObjects(2)      As String  'Corresponding Sdk name for a control, i.e., 'edit"
        Redim g_strFormProps(9)       As String  'Caption, StartUpPosition, etc
        Redim g_strTextBoxProps(6)    As String  'MultiLine, scroll bars, etc.
        Redim g_strCmdButtonProps(6)  As String  'Visible, Height, etc.
        Redim g_strEventNames(7)      As String  'Event names encountered in actual procedures, e.g., cmdButton_Click().  'Click' would be event name
        Redim g_strButtonMessages(8)  As String  'strName of button message, i.e., what is in the Hiwrd(wParam) - notification messages
      
        'Initialize string array to hold names of global VB Objects as in *.frm file, i.e., Forms, Command Buttons, Text Boxes, etc
        g_strObjects(0)="VB.Form"
        g_strObjects(1)="VB.TextBox"            :  g_strSdkObjects(1)="edit"
        g_strObjects(2)="VB.CommandButton"      :  g_strSdkObjects(2)="button"
      
        'Initial string array to hold respective property names of global VB objects.  Below is Form
        g_strFormProps(1)="Caption"
        g_strFormProps(2)="ClientHeight"
        g_strFormProps(3)="ClientLeft"
        g_strFormProps(4)="ClientTop"
        g_strFormProps(5)="ClientWidth"
        g_strFormProps(6)="LinkTopic"
        g_strFormProps(7)="ScaleHeight"
        g_strFormProps(8)="ScaleWidth"
        g_strFormProps(9)="StartUpPosition"
      
        'Initial string array to hold respective property names of global VB objects.  Below is TextBox
        g_strTextBoxProps(1)="Height"
        g_strTextBoxProps(2)="Left"
        g_strTextBoxProps(3)="TabIndex"
        g_strTextBoxProps(4)="Top"
        g_strTextBoxProps(5)="Width"
        g_strTextBoxProps(6)="Text"
      
        'Initial string array to hold respective property names of global VB objects.  Below is Push Button
        g_strCmdButtonProps(1)="Caption"
        g_strCmdButtonProps(2)="Height"
        g_strCmdButtonProps(3)="Left"
        g_strCmdButtonProps(4)="TabIndex"
        g_strCmdButtonProps(5)="Top"
        g_strCmdButtonProps(6)="Width"
      
        'Load A Few VB Event Names
        g_strEventNames(1)="Load"
        g_strEventNames(2)="Click"
        g_strEventNames(3)="GotFocus"
        g_strEventNames(4)="KeyDown"
        g_strEventNames(5)="KeyPress"
        g_strEventNames(6)="Change"
        g_strEventNames(7)="Validate"
      
        g_strButtonMessages(1)="BN_CLICKED"     'I don't think I even used any of these!!!
        g_strButtonMessages(2)="BN_DBLCLK"      '
        g_strButtonMessages(3)="BN_DISABLE"     '
        g_strButtonMessages(4)="BN_PUSHED"
        g_strButtonMessages(5)="BN_KILLFOCUS"
        g_strButtonMessages(6)="BN_PAINT"
        g_strButtonMessages(7)="BN_SETFOCUS"
        g_strButtonMessages(8)="BN_UNPUSHED"
      
        'Create Objects On Form
        hCtrl=CreateWindowEx(0,"button","Locate VB Project",%WS_CHILD Or %WS_VISIBLE,15,20,130,25,wea.hWnd,%BTN_LOAD_VB_PROJECT,wea.hInst,ByVal 0)
        hCtrl=CreateWindowEx(%WS_EX_CLIENTEDGE,"edit","",%WS_CHILD Or %WS_VISIBLE,155,20,430,25,wea.hWnd,%TXT_VB_PROJECT,wea.hInst,ByVal 0)
        hCtrl=CreateWindowEx(0,"button","Convert VB Project",%WS_CHILD Or %WS_VISIBLE,300,60,130,25,wea.hWnd,%BTN_CONVERT_VB_PROJECT,wea.hInst,ByVal 0)
      
        fnWndProc_OnCreate=0
      End Function
      
      
      Sub OnOpen(wea As WndEventArgs)
        Local szTitleName As Asciiz*(%MAX_FNAME+%MAX_EXT)
        Local szFileName As Asciiz*%MAX_PATH
        Local szIniDir As Asciiz*256
        Local strFilter As String
        Local ofn As OPENFILENAME
        
        strFilter="frm files (*.frm)"+Chr$(0)+"*.frm"+Chr$(0)+Chr$(0)   
        'szIniDir="C:\Code\VStudio\VB6"
        szIniDir="C:\Program Files\Microsoft Visual Studio\VB98\Projects\vbConvert"
        ofn.lStructSize=SizeOf(OPENFILENAME)
        ofn.hWndOwner=Wea.hWnd
        ofn.hInstance=wea.hInst
        ofn.lpstrFilter=StrPtr(strFilter)
        ofn.nMaxFile=%MAX_PATH
        ofn.nMaxFileTitle=%MAX_FNAME+%MAX_EXT
        ofn.lpstrInitialDir = VarPtr(szIniDir)
        ofn.lpstrDefExt=%NULL
        ofn.Flags=%OFN_HIDEREADONLY Or %OFN_CREATEPROMPT
        ofn.lpstrFile=VarPtr(szFileName)
        ofn.lpstrFileTitle=VarPtr(szTitleName)
        Call GetOpenFileName(ofn)
        If szFileName<>"" Then
           Call SetWindowText(GetDlgItem(Wea.hWnd,%TXT_VB_PROJECT),szFileName)
        Else
           MsgBox("You Must Have Cancelled!")
        End If
      End Sub
      
      
      Function blnLoadVbObjs(fp As Long, strArr() As String, vbObj() As vbObject) As Long
        Register i As Long, j As Long
        Local blnFound As Long
        Local iCtr As Long
      
        For i=1 To UBound(strArr,1)
          If InStr(strArr(i),"Begin") Then
             blnFound=%FALSE
             For j=0 To UBound(g_strObjects,1)
               If InStr(strArr(i),g_strObjects(j)) Then
                  blnFound=%True
                  vbObj(iCtr).szObject=g_strObjects(j)
                  vbObj(iCtr).szSdkControl=g_strSdkObjects(j)
                  Incr iCtr
                  Exit For
               End If
             Next j
             If blnFound=%FALSE Then
                Print #fp, "Unidentified VB Object!"
                blnLoadVbObjs=%FALSE
                Exit Function
             End If
          End If
        Next i
      
        blnLoadVbObjs=%TRUE
      End Function
      
      
      Function strGetObjName(fp As Long, strArr() As String, iRec As Long) As String
        Local iSpace,iLenStr,iNum As Long
        Register i As Long
      
        iLenStr=Len(strArr(iRec))
        For i=iLenStr -2 To 1 Step -1
          If Mid$(strArr(iRec),i,1)=" " Then
             iSpace=i
             Exit For
          End If
        Next i
      
        strGetObjName=Trim$(Right$(strArr(iRec),iLenStr-iSpace))
      End Function
      
      
      Function strGetVariableType(strDeclaration As String) As String
        Local iLenStr,iSpace As Long
        Register i As Long
      
        iLenStr=Len(strDeclaration)
        For i=iLenStr To 1 Step -1
          If Mid$(strDeclaration,i,1)=" " Then
             iSpace=i
             Exit For
          End If
        Next i
      
        strGetVariableType=Trim$(Right$(strDeclaration,iLenStr-iSpace))
      End Function
      
      
      Function blnLoadObjProperties(fp As Long, strArr() As String, vbObj() As vbObject) As Long
        Local blnFound,iCtr,iStart,i,iPos As Long
        Register j As Long, k As Long
      
        'Print
        'Print "Entering blnLoadObjProperties()"
        'Find beginning and end of Form properties
        For i=0 To Ubound(strArr,1)
          If Instr(strArr(i),"Begin VB.Form") Then
             vbObj(0).iBegin=i
             blnFound=%TRUE
             Iterate For
          End If
          If blnFound Then
             If Instr(strArr(i),"Begin ") Then
                vbObj(0).iEnd=i-1
                Exit For
             End If
          End If
        Next i
        iStart=i
        Incr iCtr 'vbObj(0) Already Found
        'Print "vbObj(0).iBegin   = "vbObj(0).iBegin
        'Print "vbObj(0).iEnd     = "vbObj(0).iEnd
      
        'Find Beginning and End Of Other Object Properties
        iCtr=1
        For i=iStart To UBound(strArr,1)
          If Instr(strArr(i),"Begin ") Then
             If InStr(strArr(i),vbObj(iCtr).szObject) Then
                vbObj(iCtr).iBegin=i
             End If
             For j=i To UBound(strArr,1)
               If InStr(strArr(j),"End") Then
                  vbObj(iCtr).iEnd=j-1
                  Incr iCtr
                  Exit For
               End If
             Next j
          End If
        Next i
      
        For i=0 To UBound(vbObj,1)
          vbObj(i).szName=strGetObjName(fp,strArr(),vbObj(i).iBegin)
          iStart=vbObj(i).iBegin+1
          Select Case vbObj(i).szObject
            Case "VB.Form"
              If i=0 Then
                 vbObj(0).szSdkControl=vbObj(0).szName
              End If
              For j=iStart To vbObj(i).iEnd
                If InStr(strArr(j),"Caption") Then
                   iPos=InStr(strArr(j),Chr$(34))
                   vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
                End If
                If InStr(strArr(j),"ScaleHeight") Then
                   vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                End If
                If InStr(strArr(j),"ScaleWidth") Then
                   vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                End If
                If InStr(strArr(j),"StartUpPosition") Then
                   vbObj(i).X=400
                   vbObj(i).Y=300
                End If
                vbObj(i).dwStyle=%WS_OVERLAPPEDWINDOW
                vbObj(i).dwExStyle=0
              Next j
            Case "VB.TextBox"
              For j=iStart To vbObj(i).iEnd
                If InStr(strArr(j),"Height") Then
                   vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                End If
                If InStr(strArr(j),"Width") Then
                   vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                End If
                If InStr(strArr(j),"Left") Then
                   vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                End If
                If InStr(strArr(j),"Top") Then
                   vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                End If
                vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE
                vbObj(i).dwExStyle=%WS_EX_CLIENTEDGE
              Next j
            Case "VB.CommandButton"
              For j=iStart To vbObj(i).iEnd
                If InStr(strArr(j),"Caption") Then
                   iPos=InStr(strArr(j),Chr$(34))
                   vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
                End If
                If InStr(strArr(j),"Height") Then
                   vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                End If
                If InStr(strArr(j),"Width") Then
                   vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                End If
                If InStr(strArr(j),"Left") Then
                   vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                End If
                If InStr(strArr(j),"Top") Then
                   vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                End If
                vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE Or %BS_NOTIFY
                vbObj(i).dwExStyle=0
              Next j
          End Select
          If i Then  'Form Equate By Concatenating Form Name (szObj(0)) To Control Name With Underscore In Middle
             vbObj(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
          Else       'Its the Main Form
             vbObj(i).szEquate="%" & vbObj(0).szName
          End If
        Next i
        'Print
        'Print " i vbObj(i).szObject    Sdk           Begin  End vbObj(i).szName      Ht   Wd   X    Y   Caption                              szEquate"
        'Print "======================================================================================================================================"
        'For i=0 To UBound(vbObj,1)
        '  Print i Tab(4) vbObj(i).szObject Tab(25) vbObj(i).szSdkControl Tab(40) vbObj(i).iBegin Tab(45) vbObj(i).iEnd _
        '  Tab(50) vbObj(i).szName Tab(70) vbObj(i).Height Tab(75) vbObj(i).Width Tab(80) vbObj(i).X Tab(85) vbObj(i).Y _
        '  Tab(90) vbObj(i).szCaption Tab(120) vbObj(i).szEquate
        'Next i
        'Print
        'Print "Leaving blnLoadObjProperties()"
        'Print
      
        blnLoadObjProperties=%TRUE
      End Function
      
      
      Function blnLoadVbProcs(fp As Long, strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure) As Long
        Register i As Long, j As Long
        Local iCtr As Long
      
        Print #fp,
        Print #fp, "Entering blnLoadVbProcs()"
        Print #fp,
        Print #fp, " iCtr  szType    vbProc(iCtr).szNewSymbol            iType  iBegin    iEnd   blnContainsObject blnContainsUnderscore  szObjectName   szEventName     szOriginalName"
        Print #fp, "==================================================================================================================================================================="
        For i=0 To Ubound(strArr,1)
          If Instr(strArr(i),"Private Sub") Then
             vbProc(iCtr).szType="Sub"
             vbProc(iCtr).iType=0
             vbProc(iCtr).iBegin=i                  'This is the line number where a Sub begins
             For j=i To UBound(strArr,1)            'Find out line number where Sub Ends
               If InStr(strArr(j),"End Sub") Then
                  vbProc(iCtr).iEnd=j
                  Exit For
               End If
             Next j
             For j=0 To UBound(vbObj,1)                  'Now find out if a control name stored in vbObj()
               If InStr(strArr(i),vbObj(j).szName) Then  'is in procedure name, i.e., cmdButton1
                  vbProc(iCtr).blnContainsObject=%TRUE
                  vbProc(iCtr).szObjectName=vbObj(j).szName
                  vbProc(iCtr).szSdkObjectType=vbObj(j).szSdkControl
                  Exit For
               End If
             Next j
             For j=i To UBound(strArr,1)            'Find out if procedure line contains underscore
               If InStr(strArr(j),"_") Then
                  vbProc(iCtr).blnContainsUnderscore=%TRUE
                  Exit For
               End If
             Next j
             For j=1 To UBound(g_strEventNames,1)
               If InStr(strArr(i),g_strEventNames(j)) Then
                  vbProc(iCtr).blnContainsEventName=%TRUE
                  vbProc(iCtr).szEventName=g_strEventNames(j)
                  Exit For
               End If
             Next j
             If vbProc(iCtr).blnContainsObject Then
                If vbProc(iCtr).blnContainsUnderscore Then
                   If vbProc(iCtr).blnContainsEventName Then
                      vbProc(iCtr).blnEventProcedure=%TRUE
                   End If
                End If
             End If
             If vbProc(iCtr).blnEventProcedure Then
                vbProc(iCtr).szOriginalSymbol=vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
                vbProc(iCtr).szNewSymbol=vbObj(0).szName & "_" & vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
             End If
             Print #fp, iCtr Tab(8) vbProc(iCtr).szType Tab(18) vbProc(iCtr).szNewSymbol Tab(53) vbProc(iCtr).iType Tab(60) vbProc(iCtr).iBegin Tab(70) vbProc(iCtr).iEnd _
             Tab(77) vbProc(iCtr).blnContainsObject Tab(95) vbProc(iCtr).blnContainsUnderscore Tab(120) vbProc(iCtr).szObjectName _
             Tab(135) vbProc(iCtr).szEventName Tab(150) vbProc(iCtr).szOriginalSymbol
             Incr iCtr
          End If
          If InStr(strArr(i),"Public Sub") Then
             Print #fp, iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
             Incr iCtr
          End If
          If InStr(strArr(i),"Private Function") Then
             Print #fp, iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
             Incr iCtr
          End If
          If InStr(strArr(i),"Public Function") Then
             Print #fp, iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
             Incr iCtr
          End If
        Next i
      
        'Count Event Procedures For Each Object And Store In vbObj().  This Will Be Useful To Know Later.
        Print #fp, : Print #fp,
        For i=0 To UBound(vbObj,1)
          iCtr=0
          For j=0 To UBound(vbProc,1)
            If vbObj(i).szName=vbProc(j).szObjectName Then
               Incr iCtr
            End If
          Next j
          vbObj(i).iCountEvents=iCtr
        Next i
        Print #fp, " i            vbObj(i).szName      vbObj(i).iCountEvents"
        Print #fp, "========================================================"
        For i=0 To UBound(vbObj,1)
          Print #fp, i,vbObj(i).szName,,vbObj(i).iCountEvents
        Next i
        Print #fp,
        Print #fp, "Leaving blnLoadVbProcs()"
        Print #fp,
      
        blnLoadVbProcs=%TRUE
      End Function
      
      
      Function blnFindOutWhatItIs(strObj As String, vbLn As vbCodeLine, vbSym() As vbSymbolTable) As Long
        Local blnFound As Long
        Register i As Long
      
        For i=0 To UBound(vbSym,1)
          If strObj=vbSym(i).szSymbol Then
             blnFound=%TRUE
             'vbLn.    =vbSym.szGeneralType
          End If
        Next i
      End Function
      
      
      Function iCountVariables(strArr() As String) As Long
        Register i As Long
        Local iCtr As Long
      
        For i=0 To UBound(strArr,1)
          If InStr(strArr(i),"Dim") Then
             Incr iCtr
          End If
        Next i
      
        iCountVariables=iCtr
      End Function
      
      
      Sub LoadFormSymbolTable(fp As Long, strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure, vbSym() As vbSymbolTable)
        Local strTmp,strVarType As String
        Register i As Long, j As Long
      
        j=UBound(vbObj,1)
        Incr j
        For i=0 To UBound(strArr,1)
          If InStr(strArr(i),"Private Sub") Or InStr(strArr(i),"Private Function") Then
             Exit For
          End If
          If InStr(strArr(i),"Dim") Then               'You need to add functionality here to determine if its
             strTmp=Remove$(strArr(i),"Dim ")          'an array or a type/structure or not
             strVarType=strGetVariableType(strTmp)
             vbSym(j).szSpecificType=strVarType
             'vbSym(j).szSpecificType=
             vbSym(j).szSymbol=Left$(strTmp,Instr(strTmp," ")-1)
             vbSym(j).Scope=1
             'Print #fp,"strTmp="strTmp
             Incr j
          End If
        Next i
        For i=0 To UBound(vbProc,1)
          vbSym(j).szSymbol=vbProc(i).szOriginalSymbol
          vbSym(j).iGeneralType=3
          vbSym(j).szSpecificType=vbProc(i).szType
          Incr j
        Next i
      End Sub
      
      
      Function iIdentifyTerm(fp As Long, szTerm As Asciiz*256, vbSym() As vbSymbolTable, iGenType As Long, szSpecType As Asciiz*24, iSymbol As Long) As Long
        Register i As Long, j As Long
      
        'Print #fp,
        'Print #fp,"Entering blnIdentifyTerm()"
        If Left$(szTerm,1)=Chr$(34) And Right$(szTerm,1)=Chr$(34) And Tally(szTerm,Chr$(34))=2 Then  'Its a simple string constant
           'Print #fp, "It Looks A Lot Like A String Constant!"
           iIdentifyTerm=2                                   'We're obviously going to need to handle situations such as...
           Exit Function                                     '"His Last Name Is " & txtLastName.Text & " And He Lives At "
        End If
        'We'll need code to recognize numeric constants!!!  But will get to that later!!!
        For i=0 To UBound(vbSym)                  'See if one of the symbols in the Symbol Table can be
          If Instr(szTerm,vbSym(i).szSymbol) Then 'found in the Term passed to this function.
             'blnFound=%TRUE
             'Print #fp, "We Found Something!!!!!!"
             'Print #fp, "We Found Something!!!!!!"
             iGenType=vbSym(i).iGeneralType
             szSpecType=vbSym(i).szSpecificType
             iIdentifyTerm=3
             iSymbol=i
             Exit Function
             Exit For
          End If
        Next i
        'Print #fp, "Leaving blnIdentifyTerm()"
      
        iIdentifyTerm=0
      End Function
      
      
      Function blnDoTextBoxCode(fp As Long, vbSym() As vbSymbolTable, iSymbol As Long, vbLn As vbCodeLine, strWorkBuffer() As String) As Long
        Local strObjectCall As String
        Register i As Long, j As Long
      
      '  Print #fp, "Entering blnDoTextBoxCode()"
      '  Print #fp, "vbLn.vbAssignment.LeftTerm          = " vbLn.vbAssignment.LeftTerm.szTerm
      '  Print #fp, "vbLn.vbAssignment.LeftTermIdentity  = " vbLn.vbAssignment.LeftTermIdentity
      '  Print #fp, "vbLn.vbAssignment.RightTerm         = " vbLn.vbAssignment.RightTerm.szTerm
      '  Print #fp, "vbLn.vbAssignment.RightTermIdentity = " vbLn.vbAssignment.RightTermIdentity
        Select Case As Long vbLn.vbAssignment.LeftTermIdentity
          Case %vbObject
            'Print #fp, "The Left Term Is An Object Of Type VB.TextBox"
          Case %Integer
            'Print #fp, "The Left Term Is An Integer"
        End Select
        Select Case As Long vbLn.vbAssignment.RightTermIdentity
          Case %StringConstant
            'Print #fp, "The Right Term Is A String Constant"
          Case %vbObject
            'Print #fp, "The Right Term Is An Object Of Type VB.TextBox"
          Case %Integer
            'Print #fp, "The Right Term Is An Integer"
        End Select
        'Print #fp,
        If InStr(vbLn.vbAssignment.LeftTerm.szTerm,".") Then
           strObjectCall= _
           Right$(vbLn.vbAssignment.LeftTerm.szTerm,Len(vbLn.vbAssignment.LeftTerm.szTerm)-Instr(vbLn.vbAssignment.LeftTerm.szTerm,"."))
           'Print #fp, "strObjectCall      = " strObjectCall
           'Print #fp, "Len(strObjectCall) = " Len(strObjectCall)
           For i=1 To UBound(g_strTextBoxProps)
             If strObjectCall=g_strTextBoxProps(i) Then
                Select Case g_strTextBoxProps(i)
                  Case "Height"
      
                  Case "Left"
      
                  Case "Text"
                    strWorkBuffer(j)= "  Call SetWindowText(GetDlgItem(Wea.hWnd," & Trim$(vbSym(iSymbol).szEquate) & ")," & _
                    vbLn.vbAssignment.RightTerm.szTerm & ")"
                End Select
                Exit For
             End If
           Next i
        Else
           'Print #fp, "Something's Badly Wrong!  I'm Outta Here!"
           Function=%FALSE
           Exit Function
        End If
        'Print #fp, "Leaving blnDoTextBoxCode()"
      
        Function=%TRUE
      End Function
      
      
      Function blnExamineLine(fp As Long, vbPrc As vbProcedure, vbSym() As vbSymbolTable, vbLn As vbCodeLine, strLine As String, strWorkBuffer() As String) As Long
        Local szSpecTypeReturn As Asciiz*24
        Local iVarReturn As Long
        Local iSymbol As Long
      
        'Print #fp,
        'Print #fp, "Entering blnExamineLine()"
        'Print #fp, "strLine       = "strLine
        Select Case vbLn.iType
          Case %Assignment
            vbLn.vbAssignment.RightTerm.szTerm=Right$(strLine,Len(strLine)-Instr(strLine,"="))
            vbLn.vbAssignment.RightTerm.szTerm=Trim$(vbLn.vbAssignment.RightTerm.szTerm)
            'Print #fp, "vbLn.vbAssignment.RightTerm.szTerm       = "vbLn.vbAssignment.RightTerm.szTerm
            Select Case As Long iIdentifyTerm(fp,vbLn.vbAssignment.RightTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol)
              Case %iIdentify_Term_Error
                 blnExamineLine=%FALSE
                 Exit Function
              Case %NumericConstant
      
              Case %StringConstant
                vbLn.vbAssignment.RightTermIdentity=%StringConstant
            End Select
            vbLn.vbAssignment.LeftTerm.szTerm=Trim$(Left$(strLine,Instr(strLine,"=")-1))
            'Print #fp, "vbLn.vbAssignment.LeftTerm.szTerm="vbLn.vbAssignment.LeftTerm.szTerm
            Select Case As Long iIdentifyTerm(fp,vbLn.vbAssignment.LeftTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol)
              Case %iIdentify_Term_Error
                 blnExamineLine=%FALSE
                 Exit Function
              Case %NumericConstant
      
              Case %StringConstant
                vbLn.vbAssignment.RightTermIdentity=%StringConstant
              Case %vbObject
                vbLn.vbAssignment.LeftTermIdentity=%vbObject
                'Print #fp,  "Ascertained Identity of Left Term To Be vbObject " vbLn.vbAssignment.LeftTerm.szTerm
                'Print #fp,  "iVarReturn       = "iVarReturn
                'Print #fp,  "szSpecTypeReturn = "szSpecTypeReturn
            End Select
            If vbLn.vbAssignment.LeftTermIdentity=%vbObject Or vbLn.vbAssignment.RightTermIdentity=%vbObject Then
               Select Case szSpecTypeReturn
                 Case "VB.Form"
      
                 Case "VB.CommandButton"
      
                 Case "VB.TextBox"
                   If blnDoTextBoxCode(fp,vbSym(),iSymbol,vbLn,strWorkBuffer()) Then
                      'Print #fp,  "Succeeded In Writing TextBox Code!"
                      'Print #fp,  strWorkBuffer(0)
                   Else
                      'Print #fp,  "Failed To Write TextBox Code!"
                   End If
                 Case "VB.ListBox"
      
              End Select
            End If
      
          Case %vbStatement
      
          Case %vbBlockStatement
      
          Case %CallProcedure
      
        End Select
        'Print #fp,  "Leaving blnExamineLine()"
      
        blnExamineLine=%TRUE
      End Function
      
      
      Function blnConvertProc(fp As Long,iProcNum As Long,iCtr As Long,strConvertedVBProc() As String,vbProc() As vbProcedure,vbSym() As vbSymbolTable) As Long
        Local strWorkBuffer() As String
        Register i As Long, j As Long
        Local vbLn As vbCodeLine
        Local iEndSub As Long
        Local iLastCodeLine As Long
        Local iFinish As Long
        Local iStart As Long
        Local iLineCtr As Long
      
        'Print #fp,
        'Print #fp, "Entering blnConvertProc()"
        iEndSub=iCtr-1
        iLastCodeLine=iEndSub-1
        'Print #fp, "iProcNum                     = " iProcNum      'The procedure number in vbProc() we're working on now
        'Print #fp, "iCtr                         = " iCtr          'One more than the number of lines written into strConvertedVBProc()
        'Print #fp, "iLastCodeLine                = " iLastCodeLine
        'Print #fp, "iEndSub                      = " iEndSub
        'Print #fp, "vbProc(iProcNum).szNewSymbol = " vbProc(iProcNum).szNewSymbol
        If vbProc(iProcNum).blnEventProcedure Then
           'Print #fp,
           strConvertedVBProc(0)="Sub " & vbProc(iProcNum).szNewSymbol & "(Wea As WndEventArgs)"
           iLineCtr=1
           For i=1 To iLastCodeLine
             Select Case Tally(strConvertedVBProc(i),"=")
               Case 0
                 'Print #fp, "No Occurances of '=' Sign"
               Case 1
                 'Print #fp, "One Occurance of '=' Sign"
                 vbLn.vbAssignment.iType=0
                 'vbLn.iType=0  'Its an assignment statement!
               Case >1
      '           Print #fp, "Multiple Occurances of '=' Sign.  Will Have To Examine This Line In Greater Detail To See What The Deal Is"
      '           Print #fp, "It May, For Example, Be An Assignment Statement Involving A String Where There Is An '=' Sign Embedded In The"
      '           Print #fp, "String To Be Assigned To Something, For Example A Textbox."
             End Select
             Redim strWorkBuffer(10) As String  'Make it arbitrarily large because we don't know how many lines of PowerBASIC code it will take to convert a VB line.
             If blnExamineLine(fp,vbProc(iProcNum), vbSym(), vbLn, strConvertedVBProc(i), strWorkBuffer()) Then
                j=0
                Do While strWorkBuffer(j)<>""
                   strConvertedVBProc(iLineCtr)=strWorkBuffer(j)
                   Incr j : Incr iLineCtr
                Loop
                Erase strWorkBuffer
             Else
                'Print #fp, "blnExamineLine() Returned %FALSE"
                blnConvertProc=%FALSE
                Exit Function
             End If
           Next i
           'Print #fp, iEndSub,strConvertedVBProc(iEndSub)
           'Print #fp,
        End If
        'Print #fp, "Leaving blnConvertProc()"
        'Print #fp,
      
        blnConvertProc=%TRUE
      End Function
      
      
      Function blnDoPBSource(fp As Long, strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure, vbSym() As vbSymbolTable) As Long
        Local strFmt1 As String*32, strFmt2 As String*8, strFmt3 As String*56, strFmt4 As String*72
        Local strString,strMsgHdlr,strMainWndProc,strAttachMsgs As String
        Local iCtr,iStart,iEnd,iProcedureCtr,iSizeOfProc,fp1 As Long
        Local strProcNames(), strSdkMsg() As String
        Local strConvertedVBProc() As String
        Register i As Long, j As Long
      
        fp1=Freefile
        Open "PBSource.bas" For Output As #fp1
        Print #fp, : Print #fp,
        Print #fp,"Entering blnDoSource()"
        Print #fp, : Print #fp,
        iCtr=1500  'used for equates
        Print #fp1,"#Compile Exe"
        Print #fp1,"#Include " & Chr$(34) & "Win32api.inc" & Chr$(34)
        For i=1 To UBound(vbObj,1)
          LSet strFmt1=vbObj(i).szEquate
          RSet strFmt2=Trim$(Str$(iCtr))
          Print #fp1,strFmt1 & "=" & strFmt2
          iCtr=iCtr+5
        Next i
        Print #fp1,
      
        Print #fp1,"Type WndEventArgs"
        Print #fp1,"  wParam As Long"
        Print #fp1,"  lParam As Long"
        Print #fp1,"  hWnd   As Dword"
        Print #fp1,"  hInst  As Dword"
        Print #fp1,"End Type"
        Print #fp1,"Declare Function FnPtr(wea As WndEventArgs) As Long"
        Print #fp1,
        Print #fp1,"Type MessageHandler"
        Print #fp1,"  wMessage As Long"
        Print #fp1,"  dwFnPtr As Dword"
        Print #fp1,"End Type"
        strMsgHdlr=vbObj(0).szName & "_" & "MsgHdlr"
        'strString="Global " & vbObj(0).szName & "_" & "MsgHdlr() As MessageHandler"
        strString="Global " & strMsgHdlr & "() As MessageHandler"
        Print #fp1,strString
        Print #fp1,
      
        Redim strProcNames(0) As String
        Redim strSdkMsg(0) As String
        strProcNames(iProcedureCtr)=vbObj(0).szName & "_" & "OnCreate"
        strSdkMsg(iProcedureCtr)="WM_CREATE"
        strString="Function " & strProcNames(iProcedureCtr) & "(wea As WndEventArgs) As Long   'Here Is Your Form_Load()"
        Print #fp1, strString
        Print #fp1,"  Local pCreateStruct As CREATESTRUCT Ptr"
        Print #fp1,"  Local hCtrl As Dword"
        Print #fp1,
        Print #fp1,"  pCreateStruct=wea.lParam"
        Print #fp1,"  [email protected]"
        For i=1 To UBound(vbObj,1)
          strString= _
          "hCtrl=" & _
          "CreateWindowEx(" & _
          Trim$(Str$(vbObj(i).dwExStyle)) & "," & _
          Chr$(34) & vbObj(i).szSdkControl & Chr$(34) & "," & _
          Chr$(34) & vbObj(i).szCaption & Chr$(34) & "," & _
          Trim$(Str$(vbObj(i).dwStyle)) & "," & _
          Trim$(Str$(vbObj(i).X)) & "," & _
          Trim$(Str$(vbObj(i).Y)) & "," & _
          Trim$(Str$(vbObj(i).Width)) & "," & _
          Trim$(Str$(vbObj(i).Height)) & "," & _
          "wea.hWnd," & _
          vbObj(i).szEquate & "," & _
          "wea.hInst,ByVal 0)"
          Print #fp1, "  " & strString
        Next i
        Print #fp1,
        Print #fp1,"  " & strProcNames(iProcedureCtr) & "=0"
        Print #fp1,"End Function"
        Print #fp1, : Print #fp1,
        
         
        For i=0 To UBound(vbProc)                             'Loop through vbProc() array
          iSizeOfProc=vbProc(i).iEnd - vbProc(i).iBegin       'How many lines?  ( this info is in vbProc() )
          Redim strConvertedVBProc(iSizeOfProc*4) As String   'Make sure it is way big enough.  The original procedure will be read into this and
          iCtr=0                                              'and passed to blnConvertProc().  Within that procedure the lines will be converted
          For j=vbProc(i).iBegin To vbProc(i).iEnd            'and more than likely moved around some from the original.  strConvertedVBProc() is
            strConvertedVBProc(iCtr)=strArr(j)                'loaded here with original lines of the procedure held in strArray(), then this new
            Incr iCtr 'at least 3 lines unless empty proc     'string array is passed to blnConvertProc().
          Next j 
          If blnConvertProc(fp,i,iCtr,strConvertedVBProc(),vbProc(),vbSym()) Then
             j=0
             Do While strConvertedVBProc(j)<>""
                Print #fp1,strConvertedVBProc(j)
                Incr j
             Loop 
          Else
             Print #fp,"blnConvertProc() Returned %FALSE"
          End If 
          Print #fp1,  :  Print #fp1,
          Erase strConvertedVBProc
        Next i                    
      
      
        'Try To Deal With WM_COMMAND.  This has been confusing for me.  What are the necessary prerequisites
        'to having a %WM_COMMAND handler in a PowerBASIC program?  I don't recall ever seeing anything like this
        'back in my VB days.  All you had were the specific event handlers for the sibling windows such as
        'command buttons and combo boxes.  However, one would have to assume the VB runtime translated WM_COMMAND
        'messages from the child window controls to the appropriate event procedure.  In any case we certainly
        'need a WM_COMMAND handler here to route messages to the appropriate button handler.  Having given this
        'some thought, I'm now at the point of thinking that if a Form has any child windows (i.e., controls) at
        'all, that would be the necessary prerequisite to blowing out a WM_COMMAND handler here.  I had been thinking
        'of some kind of complex interrogation algorithm concerning the data in vbObj() and vbProc() to determine
        'if a WM_COMMAND handler was necessary to spit out, but regarding my statements above, if the UBound() of
        'vbObj()>0 and the UBound() vbProc()>0, then I'm thinking we need WM_COMMAND.
      
        'Moved some code around in here, and now taking advantage of iCountEvents field added to vbObjects to count
        'the number of notification event handlers for each control.  Also, to receive button GotFocus messages
        'one needs to add the %BS_NOTIFY style to the button styles.  You'll find that toward the bottom of
        'blnLoadObjProperties().
        If UBound(vbObj)>0 And UBound(vbProc)>0 Then  'There are both procedures in the program, and controls on the Form
           Incr iProcedureCtr
           Redim Preserve strProcNames(iProcedureCtr) As String
           Redim Preserve strSdkMsg(iProcedureCtr) As String
           strProcNames(iProcedureCtr)=vbObj(0).szName & "_" & "OnCommand"
           strSdkMsg(iProcedureCtr)="WM_COMMAND"
           strString="Function " & vbObj(0).szName & "_" & "OnCommand(wea As WndEventArgs) As Long"
           Print #fp1,strString
           Print #fp1,"  Select Case As Long LoWrd(wea.wParam)"
           For i=1 To UBound(vbObj,1)
             If vbObj(i).iCountEvents Then
                Print #fp1,"    Case " & vbObj(i).szEquate
                Print #fp1,"      " &  "Select Case As Long HiWrd(wea.wParam)"
                For j=0 To UBound(vbProc,1)
                  If vbObj(i).szName=vbProc(j).szObjectName Then
                     If vbProc(j).szEventName="Click" Then
                        Print #fp1,"        Case %BN_CLICKED"
                        Print #fp1,"          Call " & vbObj(0).szName & "_" & vbObj(i).szName & "_" & vbProc(j).szEventName & "(wea)"
                     End If
                     If vbProc(j).szEventName="GotFocus" Then
                        Print #fp1,"        Case %BN_SETFOCUS"
                        Print #fp1,"          Call " & vbObj(0).szName & "_" & vbObj(i).szName & "_" & vbProc(j).szEventName & "(wea)"
                     End If
                  End If
                Next j
                Print #fp1,"      End Select"
             End If
           Next i
           Print #fp1,"  End Select"
           Print #fp1,
           Print #fp1,"  " & strProcNames(iProcedureCtr) & "=0"
           Print #fp1,"End Function"
           Print #fp1, : Print #fp1,
        End If
      
        'Confusing issue again!  I typically put a WM_CLOSE handler in my programs, but WM_CLOSE is possibly Form_Unload()
        'or something like that in VB - and its possible such an event might have been output above where the handlers from
        'the *.frm file were output.  So this concept needs more investigation.  So anyway, a WM_CLOSE is going here for now!
      
        Incr iProcedureCtr
        Redim Preserve strProcNames(iProcedureCtr) As String
        Redim Preserve strSdkMsg(iProcedureCtr) As String
        strProcNames(iProcedureCtr)=vbObj(0).szName & "_" & "OnClose"
        strSdkMsg(iProcedureCtr)="WM_CLOSE"
        strString="Function " & strProcNames(iProcedureCtr) & "(wea As WndEventArgs) As Long"
        Print #fp1,strString
        Print #fp1,"  Call PostQuitMessage(0)"
        Print #fp1,"  " & strProcNames(iProcedureCtr) & "=0"
        Print #fp1,"End Function"
        Print #fp1, : Print #fp,
      
        strMainWndProc=vbObj(0).szName & "_" & "WndProc"
        Print #fp1,"Function " & strMainWndProc & "(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long"
        Print #fp1,"  Local wea As WndEventArgs"
        Print #fp1,"  Register iReturn As Long"
        Print #fp1,"  Register i As Long"
        Print #fp1,
        Print #fp1,"  For i=0 To " & Trim$(Str$(UBound(strProcNames)))
        Print #fp1,"    If wMsg=" & strMsgHdlr & "(i).wMessage Then"
        Print #fp1,"       wea.hWnd=hWnd: wea.wParam=wParam: wea.lParam=lParam"
        Print #fp1,"       Call Dword " & strMsgHdlr & "(i).dwFnPtr Using FnPtr(wea) To iReturn"
        Print #fp1,"       " & strMainWndProc & "=iReturn"
        Print #fp1,"       Exit Function"
        Print #fp1,"    End If"
        Print #fp1,"  Next i"
        Print #fp1,
        Print #fp1,"  " & strMainWndProc & "=DefWindowProc(hWnd,wMsg,wParam,lParam)"
        Print #fp1,"End Function"
        Print #fp1, : Print #fp1,
      
        'Now try to create AttachMsgHdlr Proc  'Attach_frmVBConvert_MsgHdlrs
        strAttachMsgs="Attach_" & vbObj(0).szName & "_" & "MsgHdlrs"
        Print #fp1,"Sub " & strAttachMsgs & "()"
        Print #fp1,"  " & "Redim " & strMsgHdlr & "("  & Trim$(Str$(iProcedureCtr)) & ") As MessageHandler  'Associate Windows Message With Message Handlers"
        Print #fp1,
        For i=0 To UBound(strProcNames)
          LSet strFmt3=strMsgHdlr & "(" & Trim$(Str$(i)) & ").wMessage=%" & strSdkMsg(i)
          LSet strFmt4=": " & strMsgHdlr & "(" & Trim$(Str$(i)) & ").dwFnPtr=CodePtr(" & strProcNames(i) & ")"
          Print #fp1,"  " strFmt3 strFmt4
        Next i
        Print #fp1,"End Sub"
        Print #fp1, : Print #fp1,
      
        'Finally, WinMain()!!!
        Print #fp1,"Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long"
        Print #fp1,"  Local szAppName As Asciiz * 16"
        Print #fp1,"  Local winclass As WndClassEx"
        Print #fp1,"  Local hWnd As Dword"
        Print #fp1,"  Local Msg As tagMsg"
        Print #fp1,
      
        Print #fp1,"  szAppName=" & Chr$(34) & vbObj(0).szName & Chr$(34)
        Print #fp1,"  Call " & strAttachMsgs & "()"
        Print #fp1,"  winclass.cbSize=SizeOf(winclass)"
        Print #fp1,"  winclass.style=%CS_HREDRAW Or %CS_VREDRAW"
        Print #fp1,"  winclass.lpfnWndProc=CodePtr(" & strMainWndProc & ")"
        Print #fp1,"  winclass.cbClsExtra=0"
        Print #fp1,"  winclass.cbWndExtra=0"
        Print #fp1,"  winclass.hInstance=hIns"
        Print #fp1,"  winclass.hIcon=LoadIcon(%NULL, ByVal %IDI_APPLICATION)"
        Print #fp1,"  winclass.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW)"
        Print #fp1,"  winclass.hbrBackground=%COLOR_BTNFACE+1"
        Print #fp1,"  winclass.lpszMenuName=%NULL"
        Print #fp1,"  winclass.lpszClassName=VarPtr(szAppName)"
        Print #fp1,"  RegisterClassEx winclass"
        Print #fp1,"  hWnd=CreateWindowEx(0,szAppName,"+Chr$(34)+vbObj(0).szCaption+Chr$(34)+",%WS_OVERLAPPEDWINDOW,200,100,319,240,0,0,hIns,ByVal 0)"
        Print #fp1,"  Call ShowWindow(hWnd,iShow)"
        Print #fp1,"  While GetMessage(Msg,%NULL,0,0)"
        Print #fp1,"    TranslateMessage Msg"
        Print #fp1,"    DispatchMessage Msg"
        Print #fp1,"  Wend"
        Print #fp1,
        Print #fp1,"  Function=msg.wParam"
        Print #fp1,"End Function"
        Close #fp1
        Erase strProcNames, strSdkMsg
        Print #fp,
        Print #fp,"Leaving blnDoSource()"
        Print #fp,
      
        blnDoPBSource=%TRUE  'FWIW I guess if we get to here it hasn't locked up!
      End Function
      
      
      Sub OnConvert(wea As WndEventArgs)
        Local szFileToConvert As Asciiz*%MAX_PATH
        Local fp,fp1,iRecCnt,iCtr As Long
        Register i As Long, j As Long
        Local vbProc() As vbProcedure
        Local vbSym() As vbSymbolTable
        Local strArray() As String
        Local vbObj() As vbObject
      
        MousePtr 11
        Call GetWindowText(GetDlgItem(wea.hWnd,%TXT_VB_PROJECT),szFileToConvert,%MAX_PATH)
        fp=Freefile
        Open "Output.txt" For Output As #fp
        fp1=Freefile
        Open szFileToConvert For Input As #fp1
        FileScan #fp1, Records To iRecCnt
        Redim strArray(iRecCnt) As String
      
        Line Input #fp1, strArray() To iRecCnt
        Close #fp1
        For i=0 To iRecCnt
          Print #fp,strArray(i)
        Next i
        Print #fp, : Print #fp,
      
        For i=1 To iRecCnt
          If InStr(strArray(i),"Begin ") Then
             Incr iCtr
             'Print #fp,iCtr, strArray(i)
          End If
        Next i
        Decr iCtr
        Redim vbObj(iCtr) As vbObject
      
        If blnLoadVbObjs(fp,strArray(),vbObj()) Then
           Print #fp,"blnLoadVbObjs() Succeeded!"
        End If
        Print #fp,
        For i=0 To UBound(vbObj,1)
          Print #fp,i,vbObj(i).szObject
        Next i
        If blnLoadObjProperties(fp,strArray(),vbObj()) Then
           Print #fp,"blnLoadObjProperties() Succeeded!"
        End If
      
        'Find out how many procedures are in *.frm file
        iCtr=0
        For i=0 To UBound(strArray,1)
          If InStr(strArray(i),"End Sub") Or InStr(strArray(i),"End Function") Then
             Incr iCtr
          End If
        Next i
      
        Print #fp,
        Print #fp,"There Are "iCtr" Procedures In The File."
        Decr iCtr
        Redim vbProc(iCtr) As vbProcedure
        If blnLoadVbProcs(fp,strArray(),vbObj(),vbProc()) Then
           Print #fp,"blnLoadVbProcs() Succeeded!"
        Else
           Erase strArray,vbObj,vbProc
           Exit Sub
        End If
      
        'Find variables and fill symbol table
        iCtr=iCountVariables(strArray())  'at this point can't have multiple variables on one line
        Print #fp,"iCountVariables="iCtr
        Redim vbSym(iCtr+UBound(vbObj,1)+UBound(vbProc,1)+1)
        Print #fp,"Ubound(vbSym,1) = "Ubound(vbSym,1)
        For i=0 To UBound(vbObj,1)
          vbSym(i).szSymbol=vbObj(i).szName            'e.g., txtFirstName, iCtr, strLastName, etc.
          vbSym(i).iGeneralType=2
          vbSym(i).szSpecificType=vbObj(i).szObject    'Object
          vbSym(i).szSdkType=vbObj(i).szSdkControl     'edit, button, static, listbox, etc.
          vbSym(i).Scope=2
          If i Then
             vbSym(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
          Else
             vbSym(i).szEquate="%" & vbObj(0).szName
          End If        
        Next i
        Call LoadFormSymbolTable(fp,strArray(),vbObj(),vbProc(),vbSym())
        Print #fp,
        Print #fp," i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope"
        Print #fp,"=================================================================================================================="
        For i=0 To UBound(vbSym,1)
          Print #fp,i Tab(9)vbSym(i).szSymbol Tab(30)vbSym(i).iGeneralType Tab(55) vbSym(i).szSpecificType Tab(80) vbSym(i).szSdkType Tab(100) vbSym(i).Scope
        Next i
      
        'Try To Generate PowerBasic Source
        If blnDoPBSource(fp,strArray(),vbObj(),vbProc(),vbSym()) Then
           Print #fp,"Apparently Succeeded, But I doubt It!"
        Else
           Print #fp,"Failed Source Generation!  Das ist nicht gut!  Wia haben eined Fehler machen mussen!"
        End If
      
        Erase strArray,vbObj,vbProc,vbSym
        Close #fp
        MousePtr 1
      End Sub
      
      
      Function fnWndProc_OnCommand(wea As WndEventArgs) As Long
        If Lowrd(wea.wParam)=%BTN_LOAD_VB_PROJECT And Hiwrd(wea.wParam)=%BN_CLICKED Then
           Call OnOpen(wea)
        End If
        If Lowrd(wea.wParam)=%BTN_CONVERT_VB_PROJECT And Hiwrd(wea.wParam)=%BN_CLICKED Then
           Call OnConvert(wea)
        End If
      
        fnWndProc_OnCommand=0
      End Function
      
      
      Function fnWndProc_OnClose(wea As WndEventArgs) As Long
        Call PostQuitMessage(0)
        fnWndProc_OnClose=0
      End Function
      
      
      Function fnWndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long
        Register i As Long, iReturn As Long
        Local wea As WndEventArgs
      
        For i=0 To 2
          If wMsg=MsgHdlr(i).wMessage Then
             wea.hWnd=hWnd: wea.wParam=wParam: wea.lParam=lParam
             Call Dword MsgHdlr(i).dwFnPtr Using FnPtr(wea) To iReturn
             fnWndProc=iReturn
             Exit Function
          End If
        Next i
      
        fnWndProc=DefWindowProc(hWnd,wMsg,wParam,lParam)
      End Function
      
      
      Sub AttachMessageHandlers()
        ReDim MsgHdlr(2) As MessageHandler   'Associate Windows Message With Message Handlers
        MsgHdlr(0).wMessage=%WM_CREATE   :   MsgHdlr(0).dwFnPtr=CodePtr(fnWndProc_OnCreate)
        MsgHdlr(1).wMessage=%WM_COMMAND  :   MsgHdlr(1).dwFnPtr=CodePtr(fnWndProc_OnCommand)
        MsgHdlr(2).wMessage=%WM_CLOSE    :   MsgHdlr(2).dwFnPtr=CodePtr(fnWndProc_OnClose)
      End Sub
      
      
      Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long
        Local szAppName As Asciiz * 16
        Local winclass As WndClassEx
        Local Msg As tagMsg
        Local hWnd As Dword
      
        szAppName="Visual Basic Converter"
        Call AttachMessageHandlers()
        winclass.cbSize=SizeOf(winclass)                        :  winclass.style=%CS_HREDRAW Or %CS_VREDRAW
        winclass.lpfnWndProc=CodePtr(fnWndProc)                 :  winclass.cbClsExtra=0
        winclass.cbWndExtra=0                                   :  winclass.hInstance=hIns
        winclass.hIcon=LoadIcon(%NULL, ByVal %IDI_APPLICATION)  :  winclass.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW)
        winclass.hbrBackground=%COLOR_BTNFACE+1                 :  winclass.lpszMenuName=%NULL
        winclass.lpszClassName=VarPtr(szAppName)
        Call RegisterClassEx(winclass)
        hWnd=CreateWindow(szAppName,"Visual Basic Converter",%WS_OVERLAPPEDWINDOW,200,100,625,150,0,0,hIns,ByVal 0)
        Call ShowWindow(hWnd,iShow)
        While GetMessage(Msg,%NULL,0,0)
          TranslateMessage Msg
          DispatchMessage Msg
        Wend
      
        Function=msg.wParam
      End Function
      I don't think it would be too hard for someone who understands the code to add functionality to it to deal with listboxes, combo boxes, etc. I know I'm being a wild 'cowboy' here blowing all this code out, but somehow I had it in me and had to get it out. I slaved long and hard at VB for many years and hated to see what went down.
      Fred
      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

      Comment


      • #4
        However, there are some things that just send shivers down my spine. My code above won't come anywhere close to converting something like this...

        Imagine a Form name frmTest with a caption of "This Is A Form". On the Form is a button named btnExecute, and the button's caption is "Execute". Under the button is a text box named txtString and it is empty. This is the button click code

        Code:
        Private Sub btnExecute_Click()
          txtString.Text = "Caption of butten = " & btnExecute.Caption & " And Caption of Form = " & frmTest.Caption & "."
        End Sub
        ...so that when you click the button this gets put in the text box...

        Caption of butten = Execute And Caption of Form = This Is A Form.

        See how much more complicated that is! Yet somehow we'll need to routinely deal with that. If someone has a black box where something like that can get sucked in one end and the answer come out the other... well it would be nice to have!
        Fred
        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

        Comment


        • #5
          Since I wrote the above yesterday (the 11th, I think), I have been thinking about this, and now fully understand the nature of the problem. What I also fully understand is that to deal correctly with a situation as I just described above where a text string is made up of a combination of literal text constants and concatenations of object.property strings is absolutely fundamental to the VB Converter. This is a critical make or break proposition. And I don't know about you guys, but this is a tough one.

          I havn't had time to write any code since yesterday, as I've been busy with other things, but I have given it a great deal of thought as I have about a forty minute commute each way to work, and I'm a lousy sleeper. The solution I have come up with and which I hope to take a stab at coding soon is to use something like PowerBASIC's Parse function to tear out of a string all the seperate substrings delimited with '&' or '+' symbols, and then figure out individually what each one is. This will be some kind of dynamic process probably requiring first a pass through the string to count all terms, then a memory allocation or Redim to account for each substring. Each substring will need to be iIdentifyTerm()'ed to find out what it is, i.e., string literal, text in a textbox, caption of a button or Form, item from combobox/listbox, grid.cell, etc. Not trivial to say the least. At some point GetWindowText() type calls will need to be made on each 'object', and the resulting text put in a string buffer. These buffers will need to be named somehow, and dimensioned in each converted PB procedure. The resulting PB code from a statement such as the one I made in the previous post will have to look something like this

          Code:
          Local sztxtString As Asciiz*256
          Local szbtnExecute As Asciiz*64
          Local szfrmTest As Asciiz*64
          
          Call GetWindowText(GetDlgItem(Wea.hWnd,%frmTest_btnExecute),szbtnExecute,64)
          Call GetWindowText(Wea.hWnd,szfrmTest,64)
          sztxtString="Caption of button = " & szbtnExecute & " And Caption of Form = " & szfrmTest & "."
          See what I mean???
          Fred
          "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

          Comment


          • #6
            Originally posted by Fred Harris View Post
            See what I mean???
            I think so. Could you use a function returning a string to wrap the GetWindowText call? then you can string the components together rather like VB did.

            Comment


            • #7
              Fred, if it helps I have a keyword parser which I use in an editor. It will distinguish strings (quoted literals), keywords and comments. At present, it just tells the editor to color these types differently. Any use to you?

              Comment


              • #8
                Excellent idea Chris! I had been thinking about that very thing, but in another context. It hadn't occurred to me with regard to this. That might eliminate the need for the extra variable declarations too. I think I'll have time to look at it tonight or this weekend.

                In terms of parsing such strings comprised of concatenations of string literals and Object.String_Property strings, I'm not sure PowerBASIC's Parse function will work, although I havn't as of yet tried it. What I think might be the problem are delimiters ('&', '+') contained within string literals, e.g.,

                "Fred & Chris, in addition to " & txtOtherMembers.Text & "are working on this."

                Maybe someone can try this, it would be easy enough. I'm thinking the PB 'Parse' statement might stumble on this, requiring a custom made Parse.

                Yes, your parsing library might help Chris.
                Fred
                "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                Comment


                • #9
                  Just tried it. As I suspected, we'll need a custom Parse function that will not count '&' or '+' characters contained within string literals. I placed this line in a text file and read it into the program...

                  "Fred And Sam " & "Together With Alice And Cheryl " & "Will Complete This Project On Time."

                  Here is the little test program...

                  Code:
                  #Compile Exe
                  #Dim All
                  
                  Function PBMain () As Long
                    Local strParsed() As String
                    Local iParseCount As Long
                    Local strTerm As String
                    Local fp As Long
                    
                    Console Set Screen 50,120
                    fp=Freefile
                    Open "Line.txt" For Input As #fp   'file with above line in it
                    Line Input #fp, strTerm
                    Print strTerm
                    Close #fp
                    iParseCount=ParseCount(strTerm, Any "&+")
                    Print "iParseCount = "iParseCount
                    Waitkey$
                      
                    PBMain=0
                  End Function
                  ...and it produces an iParseCount=3, as expected. If you change one of the 'And' words in the above to '&' you'll get an iParseCount of 4.
                  Fred
                  "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                  Comment


                  • #10
                    Fred, this is just an example of a parser which ignores the contents of quoted strings, not the whole parser which I have to dig out of the editor! May help with the embedded delimiter problem though!

                    Code:
                    #PBFORMS CREATED V1.51
                    #COMPILE EXE
                    #DIM ALL
                    
                    #PBFORMS BEGIN INCLUDES
                    #IF NOT %DEF(%WINAPI)
                        #INCLUDE "WIN32API.INC"
                    #ENDIF
                    #PBFORMS END INCLUDES
                    
                    #PBFORMS BEGIN CONSTANTS
                    %IDD_DIALOG1  =  101
                    %IDC_TEXTBOX1 = 1001
                    %IDC_LISTBOX1 = 1002
                    %IDC_BUTTON1  = 1003
                    %IDC_LABEL1   = 1004
                    #PBFORMS END CONSTANTS
                    
                    #PBFORMS DECLARATIONS
                    '------------------------------------------------------------
                    SUB myparse ( hd AS DWORD, lCtl AS LONG, s AS STRING)
                        LOCAL bInaString AS LONG ' binary
                        LOCAL lstartString, lnonstring, lstartpos, lendpos AS LONG
                        LOCAL i AS LONG
                    
                        s = TRIM$(s)
                    
                        FOR i = 1 TO LEN(s)
                            IF MID$(s, i, 1) = $DQ THEN
                                IF lstartstring <> 0 THEN
                                    LISTBOX ADD hd, lctl, LTRIM$(MID$(s, lstartstring, i - lstartstring) + $DQ)
                                    lstartstring = 0
                                    lnonstring = i
                                ELSE
                                    lstartstring = i
                                    IF lnonstring = 1 THEN
                                        lstartpos = lnonstring
                                        lendpos = i - lnonstring
                                    ELSE
                                        lstartpos = lnonstring + 1
                                        lendpos = i - lnonstring - 1
                                    END IF
                                    LISTBOX ADD hd, lctl, TRIM$(MID$(s, lstartpos, lendpos))
                                    lnonstring = 0
                                END IF
                            ELSE
                                IF lstartstring + lnonstring = 0 THEN lnonstring = i
                            END IF
                        NEXT
                        LISTBOX ADD hd, lctl, MID$(s, MAX(lnonstring, lstartstring), i - MAX(lnonstring, lstartstring))
                    END SUB
                    '------------------------------------------------------------
                    CALLBACK FUNCTION ShowDIALOG1Proc()
                        LOCAL s AS STRING
                    
                        SELECT CASE AS LONG CBMSG
                            CASE %WM_INITDIALOG
                    
                            CASE %WM_COMMAND
                                SELECT CASE AS LONG CBCTL
                                    CASE %IDC_BUTTON1
                                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                            LISTBOX RESET CBHNDL, %IDC_listbox1
                                            CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO s
                                            myparse( CBHNDL, %idc_listbox1, s)
                                        END IF
                                END SELECT
                        END SELECT
                    END FUNCTION
                    '------------------------------------------------------------
                    
                    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                        LOCAL lRslt AS LONG
                    
                    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                        LOCAL hDlg  AS DWORD
                    
                        DIALOG NEW hParent, "parser no. 1", 101, 86, 370, 165, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR _
                            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT _
                            OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox1", 5, 30, 360, 10
                        CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX1, , 5, 45, 360, 95, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR _
                            %LBS_NOTIFY, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
                        CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "Button1", 310, 145, 55, 15
                        CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "paste or type text into textbox, press button to see parsed results", 5, 5, 170, 15
                    #PBFORMS END DIALOG
                    
                        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                    
                    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                    #PBFORMS END CLEANUP
                    
                        FUNCTION = lRslt
                    END FUNCTION
                    '------------------------------------------------------------
                    '------------------------------------------------------------
                    FUNCTION PBMAIN()
                        ShowDIALOG1 %HWND_DESKTOP
                    END FUNCTION

                    Comment


                    • #11
                      I've just spent a couple of hours stripping out my editor's parser and removing keyword recognition from it, and what's left is 200 lines of code which do what the "parser no. 1" above does in 100.

                      To summarise, "parser no. 1" is for dealing with string expressions, and text is chopped up according to delimiters, which are operators, brackets, and spaces, and character strings. The latter are preserved, any delimiters embedded within them being treated as literals.

                      So I can turn parser no. 1 into an include file, with the following functions:

                      parsecount ( s2BParsed as string ) as long
                      parse$(s2Bparsed as string, lparseitemindex as long) as string

                      Unless I hear otherwise...

                      Comment


                      • #12
                        Good deal Chris! I believe we've already got a sort of division of labor going on this. I ran your first post above and looked at it for only about five minutes and decided I'd temporarily bypass the issue and use PowerBASIC's Parse and ParseCount functions for the time being in my quest to bore ahead with getting some kind of converter code. If you would get your code working to do the job I'm pretty sure you understand, that would be great, because code sequences such as some of those outlined above occur on about every third line in VB code (if not more)!

                        Your suggestion about a wrapper that returns a string is definitely the way to go, I think. Here is my idea of how it will work. Not a real long or complicated function, but deadly for our purposes. First off, if an object - say a textbox has a name (with property) of ...

                        txtFirstName.Text

                        then use the Remove$ PB function to simply remove the '.' so as to leave...

                        txtFirstNameText

                        Then prepend an 'str' or 's' to it...

                        strtxtFirstNameText

                        That variable will need to be a Local String...

                        Local strtxtFirstNameText As String

                        Then, since functions can't return Asciiz strings, pass the uninitialized dynamic string to a function such as...

                        Sub PBGetWindowText(hParent As Dword, iCtrlId As Long, strBuffer As String)

                        called like this - Call PBGetWindowText(hMainWnd, %CtrlId, strtxtFirstNameText)

                        (I think that's legal!?)

                        ...and the var strtxtFirstNameText on return from the function will contain the VB Control's text for incorporation into the final code line. The work of the function itself will be to set up a call to DDT Get Text or Sdk GetWindowText().
                        GetTextLength can be called first there to properly set up the call.

                        Yes, as far as I'm concerned I'd really appreciate if you would perfect the parser to work on strings like that. We will of course need to have a set up like PB's Parse / ParseCount combo where the strings end up in a Redim array? Cuz will need to iterate through the array in a loop constructing the final string. A bit later I'll give an example, as I've already got things partially working with PB's Parse / ParseCount.

                        Did you ever get that VB? My offer's still good.
                        Last edited by Fred Harris; 13 Jun 2008, 07:25 PM. Reason: few more thoughts
                        Fred
                        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                        Comment


                        • #13
                          Chris, this keyword parser that you removed from the code, would we be able to substitute the VB keywords into it?

                          Rod
                          Rod
                          In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                          Comment


                          • #14
                            Piling the code on now and probably breaking half of Rodney's rules!

                            I wanted to let folks know where I'm at now with my investigation of the nature of the problems to be overcome.

                            Thanks for that code Chris. We're going to need an industrial strength parsing function for this, but at this point I'm just going to blow by it and continue with my investigations. PowerBASIC's Parse will do fine for what I'm doing here, which is just exploring the nature of the problems that will be encountered.

                            I made a new VB project. I've attached the files. If for some reason you can't get/deal with the files, to run the PB program below just copy the lines at the beginning of the output from the program as frmName.frm, save it as a txt file in the same directory as this CCParse.bas. The project name is prjName and just consists of three labels, with three adjacent text boxes, and to the right of all this is a big button with a caption of 'Execute'. The text boxes are for a persons first name, last name, and age. When the button is clicked the data from the three text boxes is concatenated together along with some literal strings to form a string such as...

                            Your Name Is Fred Harris And You Are 55 Years Old.

                            Here is the code visible in the VB IDE...

                            Code:
                            Dim iNum As Long   'not used.  just to show that it shows up in SymbolTable
                            Private Sub btnExecute_Click()
                              txtPerson.Text = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            End Sub
                            ...and that string is displayed/copied to a bottom text box on the form that is fairly wide. Here are descriptions of the various objects, and I'll actually try to attach the vb files as I see others have done.


                            Code:
                            Project Name    = prjName
                            File Name       = prjName.vbp
                            
                            Form Name       = frmName
                            Form File       = frmName.frm
                            Form Caption    = "Enter Your Name"
                            
                            
                            Controls        lblFirstName.Caption        = "First Name"
                                            lblLastName.Caption         = "Last Name"
                                            lblAge.Caption              = "Age"
                            
                                            txtFirstName.Name           = "txtFirstName"
                                            txtLastName.Name            = "txtLastName"
                                            txtAge.Name                 = "txtAge"
                            
                                            btnExecute.Name             = "btnExecute"
                                            btnExecute.Caption          = "Execute"
                            
                                            txtPerson.Name              = "txtPerson"
                                            txtPerson.Width             = 5415 twips
                            Below is the program CCParse.bas & CCParse.inc which has morphed some from my original post above to account for my progress in fguring this stuff out. The output is remmed out at the end. I'm not going to keep adding these huge code postings, but will edit this one as I make progress. And Chris, after the posting I excerpt and single out the code you want to work on.

                            First the CCParse.inc file...
                            Code:
                            'CCParse.inc
                            %LOGPIXELSX                   =   88&
                            %LOGPIXELSY                   =   90&
                            %HWND_DESKTOP                 =   0
                            %FALSE                        =   0
                            %TRUE                         =   1
                            
                            ' Window Styles
                            %WS_OVERLAPPED      = &H0
                            %WS_POPUP           = &H80000000
                            %WS_CHILD           = &H40000000
                            %WS_MINIMIZE        = &H20000000
                            %WS_VISIBLE         = &H10000000
                            %WS_DISABLED        = &H08000000
                            %WS_CLIPSIBLINGS    = &H04000000
                            %WS_CLIPCHILDREN    = &H02000000
                            %WS_MAXIMIZE        = &H01000000
                            %WS_CAPTION         = &H00C00000  ' WS_BORDER OR WS_DLGFRAME
                            %WS_BORDER          = &H00800000
                            %WS_DLGFRAME        = &H00400000
                            %WS_VSCROLL         = &H00200000
                            %WS_HSCROLL         = &H00100000
                            %WS_SYSMENU         = &H00080000
                            %WS_THICKFRAME      = &H00040000
                            %WS_GROUP           = &H00020000
                            %WS_TABSTOP         = &H00010000
                            %WS_MINIMIZEBOX     = &H00020000
                            %WS_MAXIMIZEBOX     = &H00010000
                            %WS_TILED           = %WS_OVERLAPPED
                            %WS_ICONIC          = %WS_MINIMIZE
                            %WS_SIZEBOX         = %WS_THICKFRAME
                            %WS_OVERLAPPEDWIN   = %WS_OVERLAPPED OR %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME
                            %WS_OVERLAPPEDWINDOW= %WS_OVERLAPPED OR %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX
                            %WS_EX_CLIENTEDGE   = &H00000200
                            
                            ' Button Control Styles
                            %BS_TEXT            = &H0&
                            %BS_PUSHBUTTON      = &H0&
                            %BS_DEFPUSHBUTTON   = &H1&
                            %BS_DEFAULT         = %BS_DEFPUSHBUTTON
                            %BS_CHECKBOX        = &H2&
                            %BS_AUTOCHECKBOX    = &H3&
                            %BS_RADIOBUTTON     = &H4&
                            %BS_3STATE          = &H5&
                            %BS_AUTO3STATE      = &H6&
                            %BS_GROUPBOX        = &H7&
                            %BS_USERBUTTON      = &H8&
                            %BS_AUTORADIOBUTTON = &H9&
                            %BS_OWNERDRAW       = &HB&
                            %BS_LEFTTEXT        = &H20&
                            %BS_ICON            = &H40&
                            %BS_BITMAP          = &H80&
                            %BS_LEFT            = &H100&
                            %BS_RIGHT           = &H200&
                            %BS_CENTER          = &H300&
                            %BS_TOP             = &H400&
                            %BS_BOTTOM          = &H800&
                            %BS_VCENTER         = &HC00&
                            %BS_PUSHLIKE        = &H00001000&
                            %BS_MULTILINE       = &H00002000&
                            %BS_NOTIFY          = &H00004000&
                            %BS_FLAT            = &H00008000&
                            %BS_RIGHTBUTTON     = %BS_LEFTTEXT
                            
                            DECLARE FUNCTION GetDC LIB "USER32.DLL" ALIAS "GetDC" (BYVAL hWnd AS DWORD) AS DWORD
                            DECLARE FUNCTION GetDeviceCaps LIB "GDI32.DLL" ALIAS "GetDeviceCaps" (BYVAL hdc AS DWORD, BYVAL nIndex AS LONG) AS LONG
                            DECLARE FUNCTION ReleaseDC LIB "USER32.DLL" ALIAS "ReleaseDC" (BYVAL hWnd AS DWORD, BYVAL hDC AS DWORD) AS LONG
                            
                            Global g_strObjects()         As String      'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
                            Global g_strSdkObjects()      As String      'Corresponding Sdk name for a control, i.e., 'edit"
                            Global g_strFormProps()       As String      'Caption, StartUpPosition, etc
                            Global g_strLabelProps()      As String   
                            Global g_strTextBoxProps()    As String
                            Global g_strCmdButtonProps()  As String
                            Global g_strEventNames()      As String
                            Global g_strButtonMessages()  As String
                            
                            Sub Initializations()
                              Redim g_strObjects(3)         As String  'This woud be the names of controls encountered in the *.frm file, i.e., "VB.TextBox".
                              Redim g_strSdkObjects(3)      As String  'Corresponding Sdk name for a control, i.e., 'edit"
                              Redim g_strFormProps(9)       As String  'Caption, StartUpPosition, etc
                              Redim g_strLabelProps(6)      As String  'Label Properties
                              Redim g_strTextBoxProps(6)    As String  'MultiLine, scroll bars, etc.
                              Redim g_strCmdButtonProps(6)  As String  'Visible, Height, etc.
                              Redim g_strEventNames(7)      As String  'Event names encountered in actual procedures, e.g., cmdButton_Click().  'Click' would be event name
                              Redim g_strButtonMessages(8)  As String  'strName of button message, i.e., what is in the Hiwrd(wParam) - notification messages
                            
                              'Initialize string array to hold names of global VB Objects as in *.frm file, i.e., Forms, Command Buttons, Text Boxes, etc
                              g_strObjects(0)="VB.Form"
                              g_strObjects(1)="VB.TextBox"            :  g_strSdkObjects(1)="edit"
                              g_strObjects(2)="VB.CommandButton"      :  g_strSdkObjects(2)="button"
                              g_strObjects(3)="VB.Label"              :  g_strSdkObjects(3)="static"
                              
                              'Initial string array to hold respective property names of global VB objects.  Below is Form
                              g_strFormProps(1)="Caption"
                              g_strFormProps(2)="ClientHeight"
                              g_strFormProps(3)="ClientLeft"
                              g_strFormProps(4)="ClientTop"
                              g_strFormProps(5)="ClientWidth"
                              g_strFormProps(6)="LinkTopic"
                              g_strFormProps(7)="ScaleHeight"
                              g_strFormProps(8)="ScaleWidth"
                              g_strFormProps(9)="StartUpPosition"
                            
                             'Initial string array to hold respective property names of global VB objects.  Below is Label
                              g_strLabelProps(1)="Height"
                              g_strLabelProps(2)="Left"
                              g_strLabelProps(3)="TabIndex"
                              g_strLabelProps(4)="Top"
                              g_strLabelProps(5)="Width"
                              g_strLabelProps(6)="Caption"
                            
                              'Initial string array to hold respective property names of global VB objects.  Below is TextBox
                              g_strTextBoxProps(1)="Height"
                              g_strTextBoxProps(2)="Left"
                              g_strTextBoxProps(3)="TabIndex"
                              g_strTextBoxProps(4)="Top"
                              g_strTextBoxProps(5)="Width"
                              g_strTextBoxProps(6)="Text"
                            
                              'Initial string array to hold respective property names of global VB objects.  Below is Push Button
                              g_strCmdButtonProps(1)="Caption"
                              g_strCmdButtonProps(2)="Height"
                              g_strCmdButtonProps(3)="Left"
                              g_strCmdButtonProps(4)="TabIndex"
                              g_strCmdButtonProps(5)="Top"
                              g_strCmdButtonProps(6)="Width"
                            
                              'Load A Few VB Event Names
                              g_strEventNames(1)="Load"
                              g_strEventNames(2)="Click"
                              g_strEventNames(3)="GotFocus"
                              g_strEventNames(4)="KeyDown"
                              g_strEventNames(5)="KeyPress"
                              g_strEventNames(6)="Change"
                              g_strEventNames(7)="Validate"
                            
                              g_strButtonMessages(1)="BN_CLICKED"     'I don't think I even used any of these!!!
                              g_strButtonMessages(2)="BN_DBLCLK"      '
                              g_strButtonMessages(3)="BN_DISABLE"     '
                              g_strButtonMessages(4)="BN_PUSHED"
                              g_strButtonMessages(5)="BN_KILLFOCUS"
                              g_strButtonMessages(6)="BN_PAINT"
                              g_strButtonMessages(7)="BN_SETFOCUS"
                              g_strButtonMessages(8)="BN_UNPUSHED"
                            End Sub

                            Then CCParse.bas
                            Code:
                            #Compile Exe
                            #Dim All
                            #Include "CCParse.inc"
                            
                            'Enumeration                  vbSymbolTable.iGeneralType
                            %SCALER_VARIABLE              =  0
                            %COMPLEX_VARIABLE             =  1
                            %OBJECT_VARIABLE              =  2
                            %PROCEDURE                    =  3
                            
                            'Enumeration                  Union vbCodeLine.iType
                            %Assignment                   =  0
                            %vbStatement                  =  1
                            %vbBlockStatement             =  2
                            %CallProcedure                =  3
                            
                            'Enumeration Term             (for iIdentifyTerm() Function
                            '                             and vbAssignmentStatement.LeftTermIdentity
                            '                             and vbAssignmentStatement.RightTermIdentity
                            %iIdentify_Term_Error         =  0
                            %NumericConstant              =  1
                            %StringConstant               =  2
                            %NumericExpression            =  3
                            %StringExpression             =  4
                            %vbObject                     =  5
                            %Integer                      =  6
                            %Long                         =  7
                            %Single                       =  8
                            %Double                       =  9
                            %Currency                     =  10
                            %Variant                      =  11
                            %String                       =  12
                            
                            Type vbObject
                              szObject                    As Asciiz*24
                              szName                      As Asciiz*32
                              szCaption                   As Asciiz*64
                              szSdkControl                As Asciiz*16
                              szEquate                    As Asciiz*64
                              iBegin                      As Long
                              iEnd                        As Long
                              Width                       As Long
                              Height                      As Long
                              X                           As Long
                              Y                           As Long
                              TabIndex                    As Long
                              iCountEvents                As Long
                              dwExStyle                   As Dword
                              dwStyle                     As Dword
                            End Type
                            
                            Type vbProcedure
                              szType                      As Asciiz*16   'Can be Sub or Function
                              iType                       As Long        '0=Sub / 1=Function
                              iBegin                      As Long        'What line in frm file?
                              iEnd                        As Long        'Line # of End Sub or End Function
                              blnContainsObject           As Long        '%TRUE / %FALSE Does the string contain a control in the *.frm file
                              blnContainsUnderscore       As Long        'Is there an underscore in the name?
                              blnContainsEventName        As Long        'Event name found in string?
                              szObjectName                As Asciiz*16   'Name of control if event procedure for control
                              szSdkObjectType             As Asciiz*16   'button, edit, static, listbox, etc
                              szEventName                 As Asciiz*16   'Click, Keypress, Change, etc
                              szOriginalSymbol            As Asciiz*64
                              szNewSymbol                 As Asciiz*64
                              blnRequiresWMCommand        As Long        'Will this procedure be routed from WM_COMMAND message?
                              blnEventProcedure           As Long        'Using the above gleaned info, is it an Event Procedure (%TRUE / %FALSE)?
                            End Type
                            
                            Type vbSymbolTable
                              szSymbol                    As Asciiz*64   'e.g, txtFirstName, iNumber, strDate, etc.
                              iGeneralType                As Long        'enumeration, i.e., simple scaler variable=0, complex variable=1, object variable=2, procedure=3
                              szSpecificType              As Asciiz*24   '"TextBox", "CommonDialog", "Database", "Integer", "String", "Variant", "Sub", "Function", etc.
                              blnArray                    As Long        'TRUE/FALSE. Could be an array of almost anything, e.g., textboxes, databases, integers, blnSymbolTables, whatever.
                              szSdkType                   As Asciiz*16   'edit,button, etc.
                              Scope                       As Long        '0=Local, 1=Form, 2=Public, 3=Static
                              szEquate                    As Asciiz*64   'Put equate here if its an object
                            End Type
                            
                            Type Term
                              szTerm As Asciiz*256                    '256
                            End Type
                            
                            Type vbAssignmentStatement
                              iType                        As Long
                              LeftTerm                     As Term    '256
                              RightTerm                    As Term    '256
                              LeftTermIdentity             As Long    '  4  1=%NumericConstant, 2=%StringConstant, 3=vbObject, 4=%Integer, 5=%Long, 6=%Single, 7=%Double, etc
                              RightTermIdentity            As Long    '  4  ditto
                            End Type
                            
                            Type vbStatement
                              iType                        As Long
                              szReservedWord               As Asciiz*16             '16
                              szArguements                 As Asciiz*48             '48
                            End Type
                            
                            Type vbBlockStatement
                              iType                        As Long
                              szStatement                  As Asciiz*32
                            End Type
                            
                            Union vbCodeLine
                              iType                        As Long
                              vbAssignment                 As vbAssignmentStatement
                              vbVerb                       As vbStatement
                              vbBlock                      As vbBlockStatement
                            End Union
                            
                            Function TwipsPerPixelX() As Single
                              Dim lngDC As Long
                            
                              lngDC = GetDC(%HWND_DESKTOP)
                              TwipsPerPixelX=1440&/GetDeviceCaps(lngDC,%LOGPIXELSX)
                              Call ReleaseDC(%HWND_DESKTOP,lngDC)
                            End Function
                            
                            
                            Function TwipsPerPixelY() As Single     'blasted vb dimensions
                              Dim lngDC As Long                     'are in Twips!!!!!!!!!
                            
                              lngDC=GetDC(%HWND_DESKTOP)
                              TwipsPerPixelY=1440&/GetDeviceCaps(lngDC,%LOGPIXELSY)
                              Call ReleaseDC(%HWND_DESKTOP,lngDC)
                            End Function
                            
                            
                            Function strGetObjName(strArr() As String, iRec As Long) As String
                              Local iSpace,iLenStr,iNum As Long
                              Register i As Long
                            
                              iLenStr=Len(strArr(iRec))
                              For i=iLenStr -2 To 1 Step -1
                                If Mid$(strArr(iRec),i,1)=" " Then
                                   iSpace=i
                                   Exit For
                                End If
                              Next i
                            
                              strGetObjName=Trim$(Right$(strArr(iRec),iLenStr-iSpace))
                            End Function
                            
                            
                            Function strGetVariableType(strDeclaration As String) As String
                              Local iLenStr,iSpace As Long
                              Register i As Long
                            
                              iLenStr=Len(strDeclaration)
                              For i=iLenStr To 1 Step -1
                                If Mid$(strDeclaration,i,1)=" " Then
                                   iSpace=i
                                   Exit For
                                End If
                              Next i
                            
                              strGetVariableType=Trim$(Right$(strDeclaration,iLenStr-iSpace))
                            End Function
                            
                            
                            Function blnLoadObjProperties(strArr() As String, vbObj() As vbObject) As Long
                              Local blnFound,iCtr,iStart,i,iPos As Long
                              Register j As Long, k As Long
                            
                              'Print
                              'Print "Entering blnLoadObjProperties()"
                              'Find beginning and end of Form properties
                              For i=0 To Ubound(strArr,1)
                                If Instr(strArr(i),"Begin VB.Form") Then
                                   vbObj(0).iBegin=i
                                   blnFound=%TRUE
                                   Iterate For
                                End If
                                If blnFound Then
                                   If Instr(strArr(i),"Begin ") Then
                                      vbObj(0).iEnd=i-1
                                      Exit For
                                   End If
                                End If
                              Next i
                              iStart=i
                              Incr iCtr 'vbObj(0) Already Found
                              'Print "vbObj(0).iBegin   = "vbObj(0).iBegin
                              'Print "vbObj(0).iEnd     = "vbObj(0).iEnd
                            
                              'Find Beginning and End Of Other Object Properties
                              iCtr=1
                              For i=iStart To UBound(strArr,1)
                                If Instr(strArr(i),"Begin ") Then
                                   If InStr(strArr(i),vbObj(iCtr).szObject) Then
                                      vbObj(iCtr).iBegin=i
                                   End If
                                   For j=i To UBound(strArr,1)
                                     If InStr(strArr(j),"End") Then
                                        vbObj(iCtr).iEnd=j-1
                                        Incr iCtr
                                        Exit For
                                     End If
                                   Next j
                                End If
                              Next i
                            
                              For i=0 To UBound(vbObj,1)
                                vbObj(i).szName=strGetObjName(strArr(),vbObj(i).iBegin)
                                iStart=vbObj(i).iBegin+1
                                Select Case vbObj(i).szObject
                                  Case "VB.Form"
                                    If i=0 Then
                                       vbObj(0).szSdkControl=vbObj(0).szName
                                    End If
                                    For j=iStart To vbObj(i).iEnd
                                      If InStr(strArr(j),"Caption") Then
                                         iPos=InStr(strArr(j),Chr$(34))
                                         vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
                                      End If
                                      If InStr(strArr(j),"ScaleHeight") Then
                                         vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      If InStr(strArr(j),"ScaleWidth") Then
                                         vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"StartUpPosition") Then
                                         vbObj(i).X=400
                                         vbObj(i).Y=300
                                      End If
                                      vbObj(i).dwStyle=%WS_OVERLAPPEDWINDOW
                                      vbObj(i).dwExStyle=0
                                    Next j
                                  Case "VB.Label"
                                    For j=iStart To vbObj(i).iEnd
                                      If InStr(strArr(j),"Caption") Then
                                         iPos=InStr(strArr(j),Chr$(34))
                                         vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
                                      End If
                                      If InStr(strArr(j),"Height") Then
                                         vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      If InStr(strArr(j),"Width") Then
                                         vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Left") Then
                                         vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Top") Then
                                         vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE
                                      vbObj(i).dwExStyle=0
                                    Next j 
                                  Case "VB.TextBox"
                                    For j=iStart To vbObj(i).iEnd
                                      If InStr(strArr(j),"Height") Then
                                         vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      If InStr(strArr(j),"Width") Then
                                         vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Left") Then
                                         vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Top") Then
                                         vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE
                                      vbObj(i).dwExStyle=%WS_EX_CLIENTEDGE
                                    Next j
                                  Case "VB.CommandButton"
                                    For j=iStart To vbObj(i).iEnd
                                      If InStr(strArr(j),"Caption") Then
                                         iPos=InStr(strArr(j),Chr$(34))
                                         vbObj(i).szCaption=Remove$(Right$(strArr(j),Len(strArr(j))-iPos),Chr$(34))
                                      End If
                                      If InStr(strArr(j),"Height") Then
                                         vbObj(i).Height=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      If InStr(strArr(j),"Width") Then
                                         vbObj(i).Width=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Left") Then
                                         vbObj(i).X=Val(Right$(strArr(j),6))/TwipsPerPixelX()
                                      End If
                                      If InStr(strArr(j),"Top") Then
                                         vbObj(i).Y=Val(Right$(strArr(j),6))/TwipsPerPixelY()
                                      End If
                                      vbObj(i).dwStyle=%WS_CHILD Or %WS_VISIBLE Or %BS_NOTIFY
                                      vbObj(i).dwExStyle=0
                                    Next j
                                End Select
                                If i Then  'Form Equate By Concatenating Form Name (szObj(0)) To Control Name With Underscore In Middle
                                   vbObj(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
                                Else       'Its the Main Form
                                   vbObj(i).szEquate="%" & vbObj(0).szName
                                End If
                              Next i
                              'Print
                              'Print " i vbObj(i).szObject    Sdk           Begin  End vbObj(i).szName      Ht   Wd   X    Y   Caption                              szEquate"
                              'Print "======================================================================================================================================"
                              'For i=0 To UBound(vbObj,1)
                              '  Print i Tab(4) vbObj(i).szObject Tab(25) vbObj(i).szSdkControl Tab(40) vbObj(i).iBegin Tab(45) vbObj(i).iEnd _
                              '  Tab(50) vbObj(i).szName Tab(70) vbObj(i).Height Tab(75) vbObj(i).Width Tab(80) vbObj(i).X Tab(85) vbObj(i).Y _
                              '  Tab(90) vbObj(i).szCaption Tab(120) vbObj(i).szEquate
                              'Next i
                              'Print
                              'Print "Leaving blnLoadObjProperties()"
                              'Print
                            
                              blnLoadObjProperties=%TRUE
                            End Function
                            
                            
                            Function blnLoadVbObjs(strArr() As String, vbObj() As vbObject) As Long
                              Register i As Long, j As Long
                              Local blnFound As Long
                              Local iCtr As Long
                            
                              For i=1 To UBound(strArr,1)
                                If InStr(strArr(i),"Begin") Then
                                   blnFound=%FALSE
                                   For j=0 To UBound(g_strObjects,1)
                                     If InStr(strArr(i),g_strObjects(j)) Then
                                        blnFound=%True
                                        vbObj(iCtr).szObject=g_strObjects(j)
                                        vbObj(iCtr).szSdkControl=g_strSdkObjects(j)
                                        Incr iCtr
                                        Exit For
                                     End If
                                   Next j
                                   If blnFound=%FALSE Then
                                      Print "Unidentified VB Object!"
                                      blnLoadVbObjs=%FALSE
                                      Exit Function
                                   End If
                                End If
                              Next i
                            
                              blnLoadVbObjs=%TRUE
                            End Function
                            
                            
                            Function blnLoadVbProcs(strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure) As Long
                              Register i As Long, j As Long
                              Local iCtr As Long
                            
                              Print
                              Print"Entering blnLoadVbProcs()"
                              Print
                              Print " iCtr  szType    vbProc(iCtr).szNewSymbol            iType  iBegin    iEnd   blnContainsObject blnContainsUnderscore  szObjectName   szEventName     szOriginalName"
                              Print "==================================================================================================================================================================="
                              For i=0 To Ubound(strArr,1)
                                If Instr(strArr(i),"Private Sub") Then
                                   vbProc(iCtr).szType="Sub"
                                   vbProc(iCtr).iType=0
                                   vbProc(iCtr).iBegin=i                  'This is the line number where a Sub begins
                                   For j=i To UBound(strArr,1)            'Find out line number where Sub Ends
                                     If InStr(strArr(j),"End Sub") Then
                                        vbProc(iCtr).iEnd=j
                                        Exit For
                                     End If
                                   Next j
                                   For j=0 To UBound(vbObj,1)                  'Now find out if a control name stored in vbObj()
                                     If InStr(strArr(i),vbObj(j).szName) Then  'is in procedure name, i.e., cmdButton1
                                        vbProc(iCtr).blnContainsObject=%TRUE
                                        vbProc(iCtr).szObjectName=vbObj(j).szName
                                        vbProc(iCtr).szSdkObjectType=vbObj(j).szSdkControl
                                        Exit For
                                     End If
                                   Next j
                                   For j=i To UBound(strArr,1)            'Find out if procedure line contains underscore
                                     If InStr(strArr(j),"_") Then
                                        vbProc(iCtr).blnContainsUnderscore=%TRUE
                                        Exit For
                                     End If
                                   Next j
                                   For j=1 To UBound(g_strEventNames,1)
                                     If InStr(strArr(i),g_strEventNames(j)) Then
                                        vbProc(iCtr).blnContainsEventName=%TRUE
                                        vbProc(iCtr).szEventName=g_strEventNames(j)
                                        Exit For
                                     End If
                                   Next j
                                   If vbProc(iCtr).blnContainsObject Then
                                      If vbProc(iCtr).blnContainsUnderscore Then
                                         If vbProc(iCtr).blnContainsEventName Then
                                            vbProc(iCtr).blnEventProcedure=%TRUE
                                         End If
                                      End If
                                   End If
                                   If vbProc(iCtr).blnEventProcedure Then
                                      vbProc(iCtr).szOriginalSymbol=vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
                                      vbProc(iCtr).szNewSymbol=vbObj(0).szName & "_" & vbProc(iCtr).szObjectName & "_" & vbProc(iCtr).szEventName
                                   End If
                                   Print iCtr Tab(8) vbProc(iCtr).szType Tab(18) vbProc(iCtr).szNewSymbol Tab(53) vbProc(iCtr).iType Tab(60) vbProc(iCtr).iBegin Tab(70) vbProc(iCtr).iEnd _
                                   Tab(77) vbProc(iCtr).blnContainsObject Tab(95) vbProc(iCtr).blnContainsUnderscore Tab(120) vbProc(iCtr).szObjectName _
                                   Tab(135) vbProc(iCtr).szEventName Tab(150) vbProc(iCtr).szOriginalSymbol
                                   Incr iCtr
                                End If
                                If InStr(strArr(i),"Public Sub") Then
                                   Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
                                   Incr iCtr
                                End If
                                If InStr(strArr(i),"Private Function") Then
                                   Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
                                   Incr iCtr
                                End If
                                If InStr(strArr(i),"Public Function") Then
                                   Print iCtr Tab(8) vbProc(iCtr).szType Tab(23) vbProc(iCtr).iType Tab(30) vbProc(iCtr).iBegin Tab(40) vbProc(iCtr).iEnd
                                   Incr iCtr
                                End If
                              Next i
                            
                              'Count Event Procedures For Each Object And Store In vbObj().  This Will Be Useful To Know Later.
                              Print : Print
                              For i=0 To UBound(vbObj,1)
                                iCtr=0
                                For j=0 To UBound(vbProc,1)
                                  If vbObj(i).szName=vbProc(j).szObjectName Then
                                     Incr iCtr
                                  End If
                                Next j
                                vbObj(i).iCountEvents=iCtr
                              Next i
                              Print " i            vbObj(i).szName      vbObj(i).iCountEvents"
                              Print "========================================================"
                              For i=0 To UBound(vbObj,1)
                                Print i,vbObj(i).szName,,vbObj(i).iCountEvents
                              Next i
                              Print
                              Print "Leaving blnLoadVbProcs()"
                              Print
                            
                              blnLoadVbProcs=%TRUE
                            End Function
                            
                            
                            Function iCountVariables(strArr() As String) As Long
                              Register i As Long
                              Local iCtr As Long
                            
                              For i=0 To UBound(strArr,1)
                                If InStr(strArr(i),"Dim") Then
                                   Incr iCtr
                                End If
                              Next i
                            
                              iCountVariables=iCtr
                            End Function
                            
                            
                            Sub LoadFormSymbolTable(strArr() As String, vbObj() As vbObject, vbProc() As vbProcedure, vbSym() As vbSymbolTable)
                              Local strTmp,strVarType As String
                              Register i As Long, j As Long
                            
                              j=UBound(vbObj,1)
                              Incr j
                              For i=0 To UBound(strArr,1)
                                If InStr(strArr(i),"Private Sub") Or InStr(strArr(i),"Private Function") Then
                                   Exit For
                                End If
                                If InStr(strArr(i),"Dim") Then               'You need to add functionality here to determine if its
                                   strTmp=Remove$(strArr(i),"Dim ")          'an array or a type/structure or not
                                   strVarType=strGetVariableType(strTmp)
                                   vbSym(j).szSpecificType=strVarType
                                   'vbSym(j).szSpecificType=
                                   vbSym(j).szSymbol=Left$(strTmp,Instr(strTmp," ")-1)
                                   vbSym(j).Scope=1
                                   'Print #fp,"strTmp="strTmp
                                   Incr j
                                End If
                              Next i
                              For i=0 To UBound(vbProc,1)
                                vbSym(j).szSymbol=vbProc(i).szOriginalSymbol
                                vbSym(j).iGeneralType=3
                                vbSym(j).szSpecificType=vbProc(i).szType
                                Incr j
                              Next i
                            
                            End Sub
                            
                            
                            Function iIdentifyTerm(szTerm As Asciiz*256, vbSym() As vbSymbolTable, iGenType As Long, szSpecType As Asciiz*24, iSymbol As Long) As Long
                              Register i As Long, j As Long
                            
                              'Print
                              'Print "Entering blnIdentifyTerm()"
                              If Tally(szTerm,Chr$(34))=2 Then  'Its a simple string constant
                                 iIdentifyTerm=%StringConstant
                                 'Print "Looks a lot like a string constant" 
                                 'Print "Found A %StringConstant And Returning %StringConstant" 
                                 Exit Function
                              End If 
                              If Tally(szTerm,Chr$(34))>2 Or InStr(szTerm,"&") Then
                                 'Print "It Looks Like A String Expression (not Sure Though)!"
                                 iIdentifyTerm=%StringExpression
                                 'Print "Found A %StringExpression And Returning %StringExpression" 
                                 Exit Function
                              End If 
                              'Else   'The Else comes into play with something like this... "His First Name Is: " & txtName.Text   
                              '   Print "We Had Better Not See This!"                                     
                              'End If
                              'We'll need code to recognize numeric constants!!!  But will get to that later!!!
                              'Note!  The way this is presently designed, you'll want to identify Numeric Constants, String Constants, Numeric Expressions, 
                              'and String Expressions above, and Exit Function at that point.  Otherwise, you'll likely make a 'hit' down here and incorrectly
                              'identify an object.
                              For i=0 To UBound(vbSym)                  'See if one of the symbols in the Symbol Table can be
                                If Instr(szTerm,vbSym(i).szSymbol) Then 'found in the Term passed to this function.
                                   'blnFound=%TRUE
                                   'Print "We Found Something!!!!!!"
                                   'Print "We Found Something!!!!!!"
                                   iGenType=vbSym(i).iGeneralType
                                   szSpecType=vbSym(i).szSpecificType
                                   
                                   If vbSym(i).iGeneralType=2 Then
                                      iIdentifyTerm=%vbObject 
                                      'Print "Got Inside If In iIdentifyTerm()!"
                                   End If
                                   Select Case vbSym(i).szSpecificType
                                     Case "VB.Form"
                                       iIdentifyTerm=%vbObject
                                     Case "VB.TextBox"
                                       iIdentifyTerm=%vbObject
                                       'Print "Got Inside Select Case In iIdentifyTerm()!"
                                     Case "VB.CommandButton"
                                       iIdentifyTerm=%vbObject
                                     Case "VB.Label"
                                       iIdentifyTerm=%vbObject
                                     Case "Integer"
                                       iIdentifyTerm=%Integer
                                     Case "Long"
                                       iIdentifyTerm=%Long
                                     Case "Single"
                                       iIdentifyTerm=%Single
                                     Case "Double"
                                       iIdentifyTerm=%Double
                                     Case "String"
                                       iIdentifyTerm=%String
                                     Case "Variant"
                                       iIdentifyTerm=%Variant
                                   End Select            
                                   iSymbol=i    'this is the index of the item from the symbol table being returned through the iSymbol parameter in this function
                                   'Print "Found Something In The SymbolTable And Returning Something!"
                                   Exit Function
                                   Exit For
                                End If
                              Next i
                              'Print "Leaving blnIdentifyTerm()"
                            
                              iIdentifyTerm=0
                            End Function
                            
                            ''Enumeration Term             (for iIdentifyTerm() Function
                            ''                             and vbAssignmentStatement.LeftTermIdentity
                            ''                             and vbAssignmentStatement.RightTermIdentity
                            '%iIdentify_Term_Error         =  0
                            '%NumericConstant              =  1
                            '%StringConstant               =  2
                            '%NumericExpression            =  3
                            '%StringExpression             =  4
                            '%vbObject                     =  5
                            '%Integer                      =  6
                            '%Long                         =  7
                            '%Single                       =  8
                            '%Double                       =  9
                            '%Currency                     =  10
                            '%Variant                      =  11
                            
                            ' i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope  vbSym(i).szEquate
                            '=====================================================================================================================================
                            ' 0      frmName               2                       VB.Form                  frmName              2             %frmName
                            ' 1      txtPerson             2                       VB.TextBox               edit                 2             %frmName_txtPerson
                            ' 2      btnExecute            2                       VB.CommandButton         button               2             %frmName_btnExecute
                            ' 3      txtAge                2                       VB.TextBox               edit                 2             %frmName_txtAge
                            ' 4      txtLastName           2                       VB.TextBox               edit                 2             %frmName_txtLastName
                            ' 5      txtFirstName          2                       VB.TextBox               edit                 2             %frmName_txtFirstName
                            ' 6      lblAge                2                       VB.Label                 static               2             %frmName_lblAge
                            ' 7      lblLastName           2                       VB.Label                 static               2             %frmName_lblLastName
                            ' 8      lblFirstName          2                       VB.Label                 static               2             %frmName_lblFirstName
                            ' 9      iNum                  0                       Long                                          1
                            ' 10     btnExecute_Click      3                       Sub                                           0
                            
                            'Type vbSymbolTable
                            '  szSymbol                    As Asciiz*64   'e.g, txtFirstName, iNumber, strDate, etc.
                            '  iGeneralType                As Long        'enumeration, i.e., simple scaler variable=0, complex variable=1, object variable=2, procedure=3
                            '  szSpecificType              As Asciiz*24   '"TextBox", "CommonDialog", "Database", "Integer", "String", "Variant", "Sub", "Function", etc.
                            '  blnArray                    As Long        'TRUE/FALSE. Could be an array of almost anything, e.g., textboxes, databases, integers, blnSymbolTables, whatever.
                            '  szSdkType                   As Asciiz*16   'edit,button, etc.
                            '  Scope                       As Long        '0=Local, 1=Form, 2=Public, 3=Static
                            '  szEquate                    As Asciiz*64   'Put equate here if its an object
                            'End Type
                            
                            Function blnDoTextBoxCode(vbSym() As vbSymbolTable, iSymbol As Long, vbLn As vbCodeLine, strWorkBuffer() As String) As Long
                              Local strObjectCall As String
                              Register i As Long, j As Long
                              Local strTerms() As String
                              Local iParseCount As Long
                            
                              Print
                              Print "Entering blnDoTextBoxCode()"
                              Print "vbLn.vbAssignment.LeftTerm          = " vbLn.vbAssignment.LeftTerm.szTerm
                              Print "vbLn.vbAssignment.LeftTermIdentity  = " vbLn.vbAssignment.LeftTermIdentity
                              Print "vbLn.vbAssignment.RightTerm         = " vbLn.vbAssignment.RightTerm.szTerm
                              Print "vbLn.vbAssignment.RightTermIdentity = " vbLn.vbAssignment.RightTermIdentity
                              Select Case As Long vbLn.vbAssignment.LeftTermIdentity
                                Case %vbObject
                                  Print "The Left Term Is An Object Of Type VB.TextBox"
                                Case %Integer
                                  Print "The Left Term Is An Integer"
                              End Select
                              Select Case As Long vbLn.vbAssignment.RightTermIdentity
                                Case %NumericConstant
                                  Print "The Right Term Is A Numeric Constant"
                                Case %StringConstant
                                  Print "The Right Term Is A String Constant"
                                Case %NumericExpression
                                  Print "The Right Term Is A Numeric Expression"
                                Case %StringExpression
                                  Print "The Right Term Is A String Expression"  
                                Case %vbObject
                                  Print "The Right Term Is An Object Of Type VB.TextBox"
                                Case %Integer
                                  Print "The Right Term Is An Integer"
                              End Select
                              Print
                              If InStr(vbLn.vbAssignment.LeftTerm.szTerm,".") Then
                                 strObjectCall= _
                                 Right$(vbLn.vbAssignment.LeftTerm.szTerm,Len(vbLn.vbAssignment.LeftTerm.szTerm)-Instr(vbLn.vbAssignment.LeftTerm.szTerm,"."))
                                 Print "strObjectCall      = " strObjectCall
                                 Print "Len(strObjectCall) = " Len(strObjectCall)
                                 For i=1 To UBound(g_strTextBoxProps)
                                   If strObjectCall=g_strTextBoxProps(i) Then
                                      Select Case g_strTextBoxProps(i)
                                        Case "Height"
                            
                                        Case "Left"
                            
                                        Case "Text"
                                          Select Case As Long vbLn.vbAssignment.RightTermIdentity
                                            Case %StringConstant
                                              strWorkBuffer(j)= "  Call SetWindowText(GetDlgItem(Wea.hWnd," & Trim$(vbSym(iSymbol).szEquate) & ")," & _
                                              vbLn.vbAssignment.RightTerm.szTerm & ")"
                                            Case %StringExpression
                                              Print "Got In Code For %StringExpression InblnDoTextBoxCode()!!!!"
                                              vbLn.vbAssignment.RightTerm.szTerm=Trim$(vbLn.vbAssignment.RightTerm.szTerm)
                                              iParseCount=ParseCount(vbLn.vbAssignment.RightTerm.szTerm, Any "&+")
                                              Print "iParseCount = "iParseCount
                                              Redim strTerms(1 To iParseCount) As String
                                              Parse vbLn.vbAssignment.RightTerm.szTerm, strTerms(), Any "&+"
                                              Print
                                              'Function iIdentifyTerm
                                              '(
                                                'szTerm As Asciiz*256, 
                                                'vbSym() As vbSymbolTable, 
                                                'iGenType As Long, 
                                                'szSpecType As Asciiz*24, 
                                                'iSymbol As Long
                                              ') As Long
                                              Local iGenType,iSym,iIdenTerm As Long
                                              Local szSpecType As Asciz*24
                                              Print " i  strTerm(i)            enum Term     enum iGenType    idx in vbSym   vbSym.szSpecificType"
                                              Print "============================================================================================"
                                              For i=1 To UBound(strTerms)
                                                iIdenTerm=iIdentifyTerm(Byval Strptr(strTerms(i)),vbSym(),iGenType,szSpecType,iSym)
                                                Print i Tab(5) strTerms(i) Tab(26) iIdenTerm Tab(40) iGenType Tab(57) iSym Tab(73) szSpecType
                                                iSym=0 : szSpecType="" : iGenType=0  'if one doesn't do this, one gets lousy results.
                                              Next i
                                              Print   
                                          End Select    
                                      End Select
                                      Exit For
                                   End If
                                 Next i
                              Else
                                 Print "Something's Badly Wrong!  I'm Outta Here!"
                                 Function=%FALSE
                                 Exit Function
                              End If
                            
                              Print "Leaving blnDoTextBoxCode()"
                            
                              Function=%TRUE
                            End Function
                            
                            ''Enumeration Term             (for iIdentifyTerm() Function
                            ''                             and vbAssignmentStatement.LeftTermIdentity
                            ''                             and vbAssignmentStatement.RightTermIdentity
                            '%iIdentify_Term_Error         =  0
                            '%NumericConstant              =  1
                            '%StringConstant               =  2
                            '%NumericExpression            =  3
                            '%StringExpression             =  4
                            '%vbObject                     =  5
                            '%Integer                      =  6
                            '%Long                         =  7
                            '%Single                       =  8
                            '%Double                       =  9
                            '%Currency                     =  10
                            '%Variant                      =  11
                            
                            Function blnExamineLine(vbPrc As vbProcedure, vbSym() As vbSymbolTable, vbLn As vbCodeLine, strLine As String, strWorkBuffer() As String) As Long
                              Local szSpecTypeReturn As Asciiz*24
                              Local iVarReturn As Long
                              Local iSymbol As Long
                              Print
                              Print "Entering blnExamineLine()"
                              Print "strLine       = "strLine
                            
                              Select Case vbLn.iType
                                Case %Assignment
                                  vbLn.vbAssignment.RightTerm.szTerm=Right$(strLine,Len(strLine)-Instr(strLine,"="))
                                  vbLn.vbAssignment.RightTerm.szTerm=Trim$(vbLn.vbAssignment.RightTerm.szTerm)
                                  Print "vbLn.vbAssignment.RightTerm.szTerm       = "vbLn.vbAssignment.RightTerm.szTerm
                                  Select Case As Long iIdentifyTerm(vbLn.vbAssignment.RightTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol)
                                    Case %iIdentify_Term_Error
                                       blnExamineLine=%FALSE
                                       Exit Function
                                    Case %NumericConstant
                            
                                    Case %StringConstant
                                      vbLn.vbAssignment.RightTermIdentity=%StringConstant
                                    Case %NumericExpression
                                      vbLn.vbAssignment.RightTermIdentity=%NumericExpression
                                    Case %StringExpression
                                      vbLn.vbAssignment.RightTermIdentity=%StringExpression 
                                      Print "The Right Term Identity Is A String Expression"
                                  End Select
                                  vbLn.vbAssignment.LeftTerm.szTerm=Trim$(Left$(strLine,Instr(strLine,"=")-1))
                                  Print "vbLn.vbAssignment.LeftTerm.szTerm="vbLn.vbAssignment.LeftTerm.szTerm
                                  Select Case As Long iIdentifyTerm(vbLn.vbAssignment.LeftTerm.szTerm, vbSym(),iVarReturn,szSpecTypeReturn,iSymbol)
                                    Case %iIdentify_Term_Error
                                       blnExamineLine=%FALSE
                                       Exit Function
                                    Case %NumericConstant
                            
                                    Case %StringConstant
                                      vbLn.vbAssignment.RightTermIdentity=%StringConstant
                                    Case %vbObject
                                      vbLn.vbAssignment.LeftTermIdentity=%vbObject
                                      Print "Ascertained Identity of Left Term To Be vbObject " vbLn.vbAssignment.LeftTerm.szTerm
                                      Print "iVarReturn       = "iVarReturn
                                      Print "szSpecTypeReturn = "szSpecTypeReturn
                                  End Select
                                  If vbLn.vbAssignment.LeftTermIdentity=%vbObject Or vbLn.vbAssignment.RightTermIdentity=%vbObject Then
                                     Select Case szSpecTypeReturn    'this is an output parameter from iIdentifyTerm()
                                       Case "VB.Form"
                            
                                       Case "VB.CommandButton"
                            
                                       Case "VB.TextBox"
                                         If blnDoTextBoxCode(vbSym(),iSymbol,vbLn,strWorkBuffer()) Then
                                            Print "Succeeded In Writing TextBox Code!"
                                            Print strWorkBuffer(0)
                                         Else
                                            Print "Failed To Write TextBox Code!"
                                         End If
                                       Case "VB.ListBox"
                            
                                  End Select
                                  End If
                            
                                Case %vbStatement
                            
                                Case %vbBlockStatement
                            
                                Case %CallProcedure
                            
                              End Select
                            
                              Print "Leaving blnExamineLine()"
                            
                              blnExamineLine=%TRUE
                            End Function
                            
                            
                            Function blnConvertProc(iProcNum As Long, iCtr As Long, strConvertedVBProc() As String, vbProc() As vbProcedure, vbSym() As vbSymbolTable) As Long
                              Local strWorkBuffer() As String
                              Register i As Long, j As Long
                              Local vbLn As vbCodeLine
                              Local iEndSub As Long
                              Local iLastCodeLine As Long
                              Local iFinish As Long
                              Local iStart As Long
                              Local iLineCtr As Long
                              Print
                              Print "Entering blnConvertProc()"
                              iEndSub=iCtr-1
                              iLastCodeLine=iEndSub-1
                              Print "iProcNum                     = " iProcNum      'The procedure number in vbProc() we're working on now
                              Print "iCtr                         = " iCtr          'One more than the number of lines written into strConvertedVBProc()
                              Print "iLastCodeLine                = " iLastCodeLine
                              Print "iEndSub                      = " iEndSub
                              Print "vbProc(iProcNum).szNewSymbol = " vbProc(iProcNum).szNewSymbol
                              If vbProc(iProcNum).blnEventProcedure Then
                                 Print
                                 strConvertedVBProc(0)="Sub " & vbProc(iProcNum).szNewSymbol & "(Wea As WndEventArgs)"
                                 iLineCtr=1
                                 For i=1 To iLastCodeLine
                                   Select Case Tally(strConvertedVBProc(i),"=")
                                     Case 0
                                       Print "No Occurances of '=' Sign"
                                     Case 1
                                       Print "One Occurance of '=' Sign"
                                       vbLn.vbAssignment.iType=0
                                       'vbLn.iType=0  'Its an assignment statement!
                                     Case >1
                                       Print "Multiple Occurances of '=' Sign.  Will Have To Examine This Line In Greater Detail To See What The Deal Is"
                                       Print "It May, For Example, Be An Assignment Statement Involving A String Where There Is An '=' Sign Embedded In The"
                                       Print "String To Be Assigned To Something, For Example A Textbox."
                                   End Select
                                   Redim strWorkBuffer(10) As String  'Make it arbitrarily large because we don't know how many lines of PowerBASIC code it will take to convert a VB line.
                                   If blnExamineLine(vbProc(iProcNum), vbSym(), vbLn, strConvertedVBProc(i), strWorkBuffer()) Then
                                      j=0
                                      Do While strWorkBuffer(j)<>""
                                         strConvertedVBProc(iLineCtr)=strWorkBuffer(j)
                                         Incr j : Incr iLineCtr
                                      Loop
                                      Erase strWorkBuffer
                                   Else
                                      Print "blnExamineLine() Returned %FALSE"
                                      blnConvertProc=%FALSE
                                      Exit Function
                                   End If
                                 Next i
                                 Print iEndSub,strConvertedVBProc(iEndSub)
                                 Print
                              End If
                              Print "Leaving blnConvertProc()"
                              Print
                            
                              blnConvertProc=%TRUE
                            End Function
                            
                            
                            Function PBMain() As Long
                              Local strConvertedVBProc() As String
                              Local szFileToConvert As Asciiz*256
                              Local vbSym() As vbSymbolTable
                              Local vbProc() As vbProcedure
                              Register i As Long, j As Long
                              Local strArray() As String
                              Local vbLine As vbCodeLine
                              Local iSizeOfProc As Long
                              Local vbObj() As vbObject
                              Local iFinish As Long
                              Local strLn As String
                              Local iRecCnt As Long
                              Local iStart As Long
                              Local iCtr As Long
                              Local fp1 As Long
                            
                              Call Initializations()
                              'Change this line to reflect where you have frmVBConvert on your computer, or just put it in the same dir as the program.
                              'szFileToConvert="C:\Program Files\Microsoft Visual Studio\VB98\Projects\vbConvert\frmVBConvert.frm"
                              szFileToConvert="frmName.frm"
                              'szFileToConvert="frmVBConvert.frm"
                              fp1=Freefile
                              Open szFileToConvert For Input As #fp1
                              FileScan #fp1, Records To iRecCnt
                              Redim strArray(iRecCnt) As String
                              Line Input #fp1, strArray() To iRecCnt
                              Close #fp1
                              For i=0 To iRecCnt
                                Print strArray(i)
                              Next i
                              Print "Everything Above This Line Is Simply The Contents of the frmName.frm File Being Output To The Screen."
                              Print "It s Stored in strArray(), Which Was Dimensioned To Hold Its Contents.  Everything Below Is What This Program"
                              Print "Is Doing With strArray()."
                              Print
                            
                              For i=1 To iRecCnt                      '  This block of code loads vbObj() with objects found in *.frm file
                                If InStr(strArray(i),"Begin ") Then   '  "Begin " seems to be how all objects are started in the *.frm file
                                   Incr iCtr                          '  so we can find out how many there are this ay.
                                End If
                              Next i
                              Decr iCtr
                              Redim vbObj(iCtr) As vbObject
                              If blnLoadVbObjs(strArray(),vbObj()) Then     'This proc loads the just dimensioned vbObj() array with
                                 Print "blnLoadVbObjs() Succeeded!"         'info on the vb objects found in frmVBConvert.frm.  Note
                              End If                                        'we're storing the file in strArray().
                              Print : Print
                              For i=0 To UBound(vbObj,1)
                                Print i,vbObj(i).szObject
                              Next i
                              Print
                              If blnLoadObjProperties(strArray(),vbObj()) Then      'This proc gets the rest of the info into vbObj()
                                 Print "blnLoadObjProperties() Succeeded!"          'for example converting twips to pixels and so on
                              End If                                                'Lot of stuff set in the properties pane in VB IDE
                              Print : Print
                              Print " i  vbObj(i).szObject        vbObj(i).szName     vbObj(i).szSdkControl   vbObj(i).szEquate"     'Just display
                              Print "=========================================================================================="     'what we got so far
                              For i=0 To Ubound(vbObj)
                                Print i Tab(5) vbObj(i).szObject Tab(30) vbObj(i).szName Tab(50) vbObj(i).szSdkControl Tab(74) vbObj(i).szEquate
                              Next i
                            
                              'Find out how many procedures are in *.frm file      'Now lets start working on the procedures.  In this little
                              iCtr=0                                               'VB program there are only three of them
                              For i=0 To UBound(strArray,1)
                                If InStr(strArray(i),"End Sub") Or InStr(strArray(i),"End Function") Then
                                   Incr iCtr
                                End If
                              Next i
                              Print
                              Print "There Are "iCtr" Procedures In The File."
                              Decr iCtr
                              Redim vbProc(iCtr) As vbProcedure
                              If blnLoadVbProcs(strArray(),vbObj(),vbProc()) Then
                                 Print "blnLoadVbProcs() Succeeded!"
                              Else
                                 Erase strArray,vbObj,vbProc
                                 Exit Function
                              End If
                              Print : Print
                              Print " i   szType    iType  iBegin iEnd blnContainsObject blnContainsUnderscore szObjectName  szEventName   szOriginalSymbol         szNewSymbol"
                              Print "=============================================================================================================================================================="
                              For i=0 To UBound(vbProc)
                                Print i Tab(6) vbProc(i).szType Tab(15) vbProc(i).iType Tab(22) vbProc(i).iBegin Tab(29) vbProc(i).iEnd Tab(34) vbProc(i).blnContainsObject _
                                Tab(52) vbProc(i).blnContainsUnderscore Tab(75) vbProc(i).szObjectName Tab(89) vbProc(i).szEventName Tab(103) vbProc(i).szOriginalSymbol Tab(128) vbProc(i).szNewSymbol
                              Next i
                              Print
                            
                              'Find variables and fill symbol table
                              iCtr=iCountVariables(strArray())  'at this point can't have multiple variables on one line       'Now things are starting to get interesting!  It looks like
                              Print "iCountVariables="iCtr                                                                     'the concept of a 'symbol table' is something we're going to
                              Redim vbSym(iCtr+UBound(vbObj,1)+UBound(vbProc,1)+1)                                             'need.
                              Print "Ubound(vbSym,1) = "Ubound(vbSym,1)
                              Print
                              For i=0 To UBound(vbObj,1)
                                vbSym(i).szSymbol=vbObj(i).szName            'e.g., txtFirstName, iCtr, strLastName, etc.
                                vbSym(i).iGeneralType=2
                                vbSym(i).szSpecificType=vbObj(i).szObject    'Object
                                vbSym(i).szSdkType=vbObj(i).szSdkControl     'edit, button, static, listbox, etc.
                                vbSym(i).Scope=2
                                If i Then
                                   vbSym(i).szEquate="%" & vbObj(0).szName & "_" & vbObj(i).szName
                                Else
                                   vbSym(i).szEquate="%" & vbObj(0).szName
                                End If
                              Next i
                              Call LoadFormSymbolTable(strArray(),vbObj(),vbProc(),vbSym())
                              Print
                              Print " i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope  vbSym(i).szEquate"
                              Print "====================================================================================================================================="
                              For i=0 To UBound(vbSym,1)
                                Print i Tab(9)vbSym(i).szSymbol Tab(30)vbSym(i).iGeneralType Tab(55) vbSym(i).szSpecificType Tab(80) vbSym(i).szSdkType _
                                Tab(100) vbSym(i).Scope Tab(115) vbSym(i).szEquate
                              Next i
                              Print
                            
                              For i=0 To UBound(vbProc)                             'Loop through vbProc() array
                                iSizeOfProc=vbProc(i).iEnd - vbProc(i).iBegin       'How many lines?  ( this info is in vbProc() )
                                Redim strConvertedVBProc(iSizeOfProc*4) As String   'Make sure it is way big enough.  The original procedure will be read into this and
                                iCtr=0                                              'and passed to blnConvertProc().  Within that procedure the lines will be converted
                                For j=vbProc(i).iBegin To vbProc(i).iEnd            'and more than likely moved around some from the original.  strConvertedVBProc() is
                                  strConvertedVBProc(iCtr)=strArray(j)              'loaded here with original lines of the procedure held in strArray(), then this new
                                  Incr iCtr 'at least 3 lines unless empty proc     'string array is passed to blnConvertProc().
                                Next j
                                If blnConvertProc(i,iCtr,strConvertedVBProc(),vbProc(),vbSym()) Then
                                   Print "blnConvertProc() Returned %TRUE"
                                   Print: Print
                                   j=0
                                   Do While strConvertedVBProc(j)<>""
                                      Print j, strConvertedVBProc(j)
                                      Incr j
                                   Loop
                                   Print : Print
                                Else
                                   Print "blnConvertProc() Returned %FALSE"
                                End If
                                Print : Print : Print : Print
                                Erase strConvertedVBProc
                              Next i
                              Erase strArray, vbObj, vbProc, vbSym
                              Waitkey$
                            
                              PBMain=0
                            End Function
                            
                            ''BELOW IS THE COMMENTED OUT OUTPUT FROM THE ABOVE PROGRAM!  IF FOR SOME REASON YOU CAN'T GET THE ATTACHMENTS WORKING IN VB, OR DON'T HAVE VB, THEN
                            ''SIMPLY COPY THE DATA BELOW TO THE END OF THE .FRM FILE AND SAVE IT AS frmName.frm AS A TEXT FILE.  THAT IS ALL THIS PROGRAM READS.
                            
                            'VERSION 5.00
                            'Begin VB.Form frmName
                            '   Caption         =   "Enter Your Name"
                            '   ClientHeight    =   2460
                            '   ClientLeft      =   60
                            '   ClientTop       =   345
                            '   ClientWidth     =   5820
                            '   LinkTopic       =   "Form1"
                            '   ScaleHeight     =   2460
                            '   ScaleWidth      =   5820
                            '   StartUpPosition =   3  'Windows Default
                            '   Begin VB.TextBox txtPerson
                            '      Height          =   375
                            '      Left            =   240
                            '      TabIndex        =   7
                            '      Top             =   1890
                            '      Width           =   5415
                            '   End
                            '   Begin VB.CommandButton btnExecute
                            '      Caption         =   "Execute"
                            '      Height          =   855
                            '      Left            =   3930
                            '      TabIndex        =   6
                            '      Top             =   480
                            '      Width           =   1545
                            '   End
                            '   Begin VB.TextBox txtAge
                            '      Height          =   345
                            '      Left            =   1620
                            '      TabIndex        =   5
                            '      Top             =   1290
                            '      Width           =   1905
                            '   End
                            '   Begin VB.TextBox txtLastName
                            '      Height          =   345
                            '      Left            =   1620
                            '      TabIndex        =   4
                            '      Top             =   735
                            '      Width           =   1905
                            '   End
                            '   Begin VB.TextBox txtFirstName
                            '      Height          =   345
                            '      Left            =   1620
                            '      TabIndex        =   3
                            '      Top             =   210
                            '      Width           =   1905
                            '   End
                            '   Begin VB.Label lblAge
                            '      Caption         =   "Age"
                            '      Height          =   375
                            '      Left            =   270
                            '      TabIndex        =   2
                            '      Top             =   1290
                            '      Width           =   1095
                            '   End
                            '   Begin VB.Label lblLastName
                            '      Caption         =   "Last Name"
                            '      Height          =   345
                            '      Left            =   270
                            '      TabIndex        =   1
                            '      Top             =   720
                            '      Width           =   1065
                            '   End
                            '   Begin VB.Label lblFirstName
                            '      Caption         =   "First Name"
                            '      Height          =   315
                            '      Left            =   270
                            '      TabIndex        =   0
                            '      Top             =   210
                            '      Width           =   1095
                            '   End
                            'End
                            'Attribute VB_Name = "frmName"
                            'Attribute VB_GlobalNameSpace = False
                            'Attribute VB_Creatable = False
                            'Attribute VB_PredeclaredId = True
                            'Attribute VB_Exposed = False
                            'Dim iNum As Long
                            'Private Sub btnExecute_Click()
                            '  txtPerson.Text = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            'End Sub
                            
                            '^^ END OF FRM FILE AT End Sub
                            
                            'Everything Above This Line Is Simply The Contents of the frmVBConvert.frm File Being Output To The Screen.
                            'It s Stored in strArray(), Which Was Dimensioned To Hold Its Contents.  Everything Below Is What This Program
                            'Is Doing With strArray().
                            
                            'blnLoadVbObjs() Succeeded!
                            
                            
                            ' 0            VB.Form
                            ' 1            VB.TextBox
                            ' 2            VB.CommandButton
                            ' 3            VB.TextBox
                            ' 4            VB.TextBox
                            ' 5            VB.TextBox
                            ' 6            VB.Label
                            ' 7            VB.Label
                            ' 8            VB.Label
                            
                            'blnLoadObjProperties() Succeeded!
                            
                            
                            ' i  vbObj(i).szObject        vbObj(i).szName     vbObj(i).szSdkControl   vbObj(i).szEquate
                            '==========================================================================================
                            ' 0  VB.Form                  frmName             frmName                 %frmName
                            ' 1  VB.TextBox               txtPerson           edit                    %frmName_txtPerson
                            ' 2  VB.CommandButton         btnExecute          button                  %frmName_btnExecute
                            ' 3  VB.TextBox               txtAge              edit                    %frmName_txtAge
                            ' 4  VB.TextBox               txtLastName         edit                    %frmName_txtLastName
                            ' 5  VB.TextBox               txtFirstName        edit                    %frmName_txtFirstName
                            ' 6  VB.Label                 lblAge              static                  %frmName_lblAge
                            ' 7  VB.Label                 lblLastName         static                  %frmName_lblLastName
                            ' 8  VB.Label                 lblFirstName        static                  %frmName_lblFirstName
                            
                            'There Are  1  Procedures In The File.
                            
                            'Entering blnLoadVbProcs()
                            
                            ' iCtr  szType    vbProc(iCtr).szNewSymbol            iType  iBegin    iEnd   blnContainsObject blnContainsUnderscore  szObjectName   szEventName     szOriginalName
                            '===================================================================================================================================================================
                            ' 0     Sub       frmName_btnExecute_Click            0      78        80     1                 1                       btnExecute     Click          btnExecute_Click
                            
                            
                            ' i            vbObj(i).szName      vbObj(i).iCountEvents
                            '========================================================
                            ' 0            frmName                      0
                            ' 1            txtPerson                    0
                            ' 2            btnExecute                   1
                            ' 3            txtAge                       0
                            ' 4            txtLastName                  0
                            ' 5            txtFirstName                 0
                            ' 6            lblAge                       0
                            ' 7            lblLastName                  0
                            ' 8            lblFirstName                 0
                            
                            'Leaving blnLoadVbProcs()
                            
                            'blnLoadVbProcs() Succeeded!
                            
                            
                            ' i   szType    iType  iBegin iEnd blnContainsObject blnContainsUnderscore szObjectName  szEventName   szOriginalSymbol         szNewSymbol
                            '==============================================================================================================================================================
                            ' 0   Sub       0      78     80   1                 1                     btnExecute    Click         btnExecute_Click         frmName_btnExecute_Click
                            
                            'iCountVariables= 1
                            'Ubound(vbSym,1) =  10
                            
                            
                            ' i      vb.Sym(i).szSymbol    vbSym(i).iGeneralType   vbSym(i).szSpecificType  vbSym(i).szSdkType   vbSym(i).Scope  vbSym(i).szEquate
                            '=====================================================================================================================================
                            ' 0      frmName               2                       VB.Form                  frmName              2             %frmName
                            ' 1      txtPerson             2                       VB.TextBox               edit                 2             %frmName_txtPerson
                            ' 2      btnExecute            2                       VB.CommandButton         button               2             %frmName_btnExecute
                            ' 3      txtAge                2                       VB.TextBox               edit                 2             %frmName_txtAge
                            ' 4      txtLastName           2                       VB.TextBox               edit                 2             %frmName_txtLastName
                            ' 5      txtFirstName          2                       VB.TextBox               edit                 2             %frmName_txtFirstName
                            ' 6      lblAge                2                       VB.Label                 static               2             %frmName_lblAge
                            ' 7      lblLastName           2                       VB.Label                 static               2             %frmName_lblLastName
                            ' 8      lblFirstName          2                       VB.Label                 static               2             %frmName_lblFirstName
                            ' 9      iNum                  0                       Long                                          1
                            ' 10     btnExecute_Click      3                       Sub                                           0
                            
                            
                            'Entering blnConvertProc()
                            'iProcNum                     =  0
                            'iCtr                         =  3
                            'iLastCodeLine                =  1
                            'iEndSub                      =  2
                            'vbProc(iProcNum).szNewSymbol = frmName_btnExecute_Click
                            
                            'One Occurance of '=' Sign
                            
                            'Entering blnExamineLine()
                            'strLine       =   txtPerson.Text = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            'vbLn.vbAssignment.RightTerm.szTerm       = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            'The Right Term Identity Is A String Expression
                            'vbLn.vbAssignment.LeftTerm.szTerm=txtPerson.Text
                            'Ascertained Identity of Left Term To Be vbObject txtPerson.Text
                            'iVarReturn       =  2
                            'szSpecTypeReturn = VB.TextBox
                            
                            'Entering blnDoTextBoxCode()
                            'vbLn.vbAssignment.LeftTerm          = txtPerson.Text
                            'vbLn.vbAssignment.LeftTermIdentity  =  5
                            'vbLn.vbAssignment.RightTerm         = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            'vbLn.vbAssignment.RightTermIdentity =  4
                            'The Left Term Is An Object Of Type VB.TextBox
                            'The Right Term Is A String Expression
                            
                            'strObjectCall      = Text
                            'Len(strObjectCall) =  4
                            'Got In Code For %StringExpression InblnDoTextBoxCode()!!!!
                            'iParseCount =  7
                            
                            ' i  strTerm(i)            enum Term     enum iGenType    idx in vbSym   vbSym.szSpecificType
                            '============================================================================================
                            ' 1  "Your Name Is "       2             0                0
                            ' 2   txtFirstName.Text    5             2                5              VB.TextBox
                            ' 3   " "                  2             0                0
                            ' 4   txtLastName.Text     5             2                4              VB.TextBox
                            ' 5   " And You Are "      2             0                0
                            ' 6   txtAge.Text          5             2                3              VB.TextBox
                            ' 7   " Years Old."        2             0                0
                            
                            'Leaving blnDoTextBoxCode()
                            'Succeeded In Writing TextBox Code!
                            
                            'Leaving blnExamineLine()
                            ' 2            End Sub
                            
                            'Leaving blnConvertProc()
                            
                            'blnConvertProc() Returned %TRUE
                            
                            
                            ' 0            Sub frmName_btnExecute_Click(Wea As WndEventArgs)
                            ' 1              txtPerson.Text = "Your Name Is " & txtFirstName.Text & " " & txtLastName.Text & " And You Are " & txtAge.Text & " Years Old."
                            ' 2            End Sub
                            I guess I don't need to pull it out because its right close above here. Note just above the little table with seven (7) lines in it. These lines were
                            created towards the bottom of function blnDoTextBoxCode(). Here is the code...

                            Code:
                            Case %StringExpression
                              Print "Got In Code For %StringExpression In blnDoTextBoxCode()!!!!"
                              vbLn.vbAssignment.RightTerm.szTerm=Trim$(vbLn.vbAssignment.RightTerm.szTerm)
                              iParseCount=ParseCount(vbLn.vbAssignment.RightTerm.szTerm, Any "&+")          '<<<<<<<<<<<<<Note ParseCount() Call
                              Print "iParseCount = "iParseCount
                              Redim strTerms(1 To iParseCount) As String                                    'strTerms() set up ( Redim ) to hold parsed terms
                              Parse vbLn.vbAssignment.RightTerm.szTerm, strTerms(), Any "&+"
                              Print
                              'Function iIdentifyTerm                   'iIdentifyTerm() used again to identify terms (objects from symbol table)
                              '(                                        'Note in the table above 'enum Term' refers to an equate and '2' is a literal string
                                'szTerm As Asciiz*256,                  'and '5' is an object.  This is important.  I reproduce it below.  Further note that
                                'vbSym() As vbSymbolTable,              'iSym is just the index of the loop where iIdentifyTerm() located the Term in the 
                                'iGenType As Long,                      'SymbolTable.  This will all have to be redone right, I know, I know...
                                'szSpecType As Asciiz*24, 
                                'iSymbol As Long
                              ') As Long
                              Local iGenType,iSym,iIdenTerm As Long
                              Local szSpecType As Asciz*24
                              Print " i  strTerm(i)            enum Term     enum iGenType    idx in vbSym   vbSym.szSpecificType"
                              Print "============================================================================================"
                              For i=1 To UBound(strTerms)
                                iIdenTerm=iIdentifyTerm(Byval Strptr(strTerms(i)),vbSym(),iGenType,szSpecType,iSym)
                                Print i Tab(5) strTerms(i) Tab(26) iIdenTerm Tab(40) iGenType Tab(57) iSym Tab(73) szSpecType
                                iSym=0 : szSpecType="" : iGenType=0  'if one doesn't do this, one gets lousy results.
                              Next i
                            Below is what iIdentifyTerm() returns...

                            'Enumeration Term (for iIdentifyTerm() Function
                            ' and vbAssignmentStatement.LeftTermIdentity
                            ' and vbAssignmentStatement.RightTermIdentity
                            %iIdentify_Term_Error = 0
                            %NumericConstant = 1
                            %StringConstant = 2
                            %NumericExpression = 3
                            %StringExpression = 4
                            %vbObject = 5
                            %Integer = 6
                            %Long = 7
                            %Single = 8
                            %Double = 9
                            %Currency = 10
                            %Variant = 11
                            %String = 12

                            And iGenType refers to this...

                            'Enumeration vbSymbolTable.iGeneralType
                            %SCALER_VARIABLE = 0
                            %COMPLEX_VARIABLE = 1
                            %OBJECT_VARIABLE = 2
                            %PROCEDURE = 3

                            I'll try to attach the vb files. But like I said, we'll need to have the substrings from a parser in an array kind
                            of like so...

                            Code:
                            ' i  strTerm(i)            enum Term     enum iGenType    idx in vbSym   vbSym.szSpecificType
                            '============================================================================================
                            ' 1  "Your Name Is "       2             0                0
                            ' 2   txtFirstName.Text    5             2                5              VB.TextBox
                            ' 3   " "                  2             0                0
                            ' 4   txtLastName.Text     5             2                4              VB.TextBox
                            ' 5   " And You Are "      2             0                0
                            ' 6   txtAge.Text          5             2                3              VB.TextBox
                            ' 7   " Years Old."        2             0                0
                            Tomorrow and Sunday I hope to have several hours each day to work on it (also need to do some damage to some
                            English Ivy trying to take over my yard - no offense Chris).
                            Attached Files
                            Last edited by Fred Harris; 13 Jun 2008, 10:17 PM.
                            Fred
                            "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                            Comment


                            • #15
                              Fred, if you're gonna output code like that, break every rule ever made.
                              Progress isn't always by the book.
                              By the way, they aren't rules, they're guidelines and not official yet.

                              Rod
                              Rod
                              In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                              Comment


                              • #16
                                Fred, thanks for the info. As usual there are "more questions than answers" - good theme song for a project...

                                What can the RHS of the string assignment contain? My guess is, functions returning strings, properties of objects which are strings, literal strings, string equates? anything else? what is the general syntax for each of these?

                                Regarding conversion of VB string expressions, if we can get a function to return a string for each of the above object.property combinations, then a VB-like syntax can be sustained:

                                VB: mystr = "hello" & chr$(65) & txtAge.text

                                PB: mystr = "hello" & chr$(65) & PBCtlTxt(%txtAge)

                                where %txtAge is the control id, and PBCtlTxt gets the controls' text in the current dialog.

                                Food for thought?

                                PS yes, I have VB thanks, just run your example in it!

                                Comment


                                • #17
                                  I'm not sure what 'RHS' stands for? I'm sure it ought to be obvious, but sometimes (oftentimes?) I can be 'thick'.

                                  In terms of string concatenations, VB is very much like PB with the one exception of the common idiom of having Object.StringProperty items in the string. Of course, functions that return strings can also go there. I believe that might be a good next step for us to persue. I think a certain progression of complexity to follow is sort of what we are doing. In the first program all I was trying to do was to output a program architecture that would run in PB. Next was to see what was involved in clicking a button and getting a simple string literal constant put in a text box. Now we've moved on from string constants to string expressions. The algorithm to handle string expressions might even handle the special case of a string expression that is just a string constant. The only minor problem I see is that string expressions may contain some terms that don't translate exactly to PB. For example, VB uses CStr() or CStr$() and PB uses just Str$. Maybe a pre-processor would be something to think about. Convert those sorts of things before the main program has to deal with them.

                                  Anyway, today I did take the time to write the PowerBASIC program that is more or less the target I'm trying to 'hit'. Your idea about the wrapper worked out excellently as I thought it would. It worked flawlessly the first time. I named it pbGetWindowText(), and you'll find it in the code below. So, once the string expression is parsed into terms, what the converter will do is write a variable declaration for the modified textbox name, then stick that uninitialized string var in the function as the third or last parameter. When pbGetWindowText() returns that last parameter will contain the text in the text box, and the variable can just then replace the VB Object in the string expression. You'll see that in the program below. Sorry I don't have the tab order working yet, you'll have to manually move focus with the mouse. I'll get to that nasty chore too in a bit.

                                  Code:
                                  'prjPBName.bas
                                  #Compile Exe
                                  #Include "Win32api.inc"
                                  %frmName_lblFirstName    =   1200
                                  %frmName_lblLastName     =   1205
                                  %frmName_lblAge          =   1210
                                  %frmName_txtFirstName    =   1215
                                  %frmName_txtLastName     =   1220
                                  %frmName_txtAge          =   1225
                                  %frmName_txtPerson       =   1230
                                  %frmName_btnExecute      =   1235
                                  
                                  
                                  Type WndEventArgs
                                    wParam As Long
                                    lParam As Long
                                    hWnd   As Dword
                                    hInst  As Dword
                                  End Type
                                  
                                  Declare Function FnPtr(wea As WndEventArgs) As Long
                                  
                                  Type MessageHandler
                                    wMessage As Long
                                    dwFnPtr As Dword
                                  End Type
                                  Global MsgHdlr() As MessageHandler
                                  
                                  
                                  Function fnWndProc_OnCreate(wea As WndEventArgs) As Long
                                    Local pCreateStruct As CREATESTRUCT Ptr
                                    Local hCtrl As Dword
                                  
                                    pCreateStruct=wea.lParam
                                    [email protected]
                                    hCtrl=CreateWindowEx(0,"static","First Name",%WS_CHILD Or %WS_VISIBLE,20,15,80,23,wea.hWnd,%frmName_lblFirstName,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(0,"static","Last Name",%WS_CHILD Or %WS_VISIBLE,20,45,80,23,wea.hWnd,%frmName_lblLastName,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(0,"static","Age",%WS_CHILD Or %WS_VISIBLE,20,75,70,23,wea.hWnd,%frmName_lblAge,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(%WS_EX_CLIENTEDGE,"edit","",%WS_CHILD Or %WS_VISIBLE,110,15,120,23,wea.hWnd,%frmName_txtFirstName,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(%WS_EX_CLIENTEDGE,"edit","",%WS_CHILD Or %WS_VISIBLE,110,45,120,23,wea.hWnd,%frmName_txtLastName,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(%WS_EX_CLIENTEDGE,"edit","",%WS_CHILD Or %WS_VISIBLE,110,75,120,23,wea.hWnd,%frmName_txtAge,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(%WS_EX_CLIENTEDGE,"edit","",%WS_CHILD Or %WS_VISIBLE,15,120,360,23,wea.hWnd,%frmName_txtPerson,wea.hInst,ByVal 0)
                                    hCtrl=CreateWindowEx(0,"button","Execute",%WS_CHILD Or %WS_VISIBLE,260,25,100,55,wea.hWnd,%frmName_btnExecute,wea.hInst,ByVal 0)
                                  
                                    fnWndProc_OnCreate=0
                                  End Function
                                  
                                  
                                  Sub pbGetWindowText(hParent As Dword, iCtrlId As Long, strText As String)
                                    Local pszStr As Asciiz Ptr
                                    Local hCtrl As Dword
                                    Local iLen As Long
                                    
                                    hCtrl=GetDlgItem(hParent,iCtrlId)           'Retrieve handle of control with GetDlgItem()
                                    iLen=GetWindowTextLength(hCtrl)             'Retrieve length of text in control
                                    Incr iLen                                   'add extra byte for null terminator
                                    pszStr=GlobalAlloc(%GPTR,iLen)              'allocate buffer from global memory
                                    Call GetWindowText(hCtrl,Byval pszStr,iLen) 'bring text into buffer (pass address of buffer)
                                    [email protected]                             'assignment brings PB OLE String Engine into picture
                                    Call GlobalFree(pszStr)                     'release string buffer for GetWindowText()
                                  End Sub                                       'string descriptor returned through parameter
                                  
                                  
                                  Sub frmName_btnExecute_Click(Wea As WndEventArgs)
                                    Local strFirstName As String
                                    Local strLastName As String
                                    Local strPerson As String
                                    Local strAge As String
                                    
                                    Call pbGetWindowText(Wea.hWnd,%frmName_txtFirstName,strFirstName)
                                    Call pbGetWindowText(Wea.hWnd,%frmName_txtLastName,strLastName)
                                    Call pbGetWindowText(Wea.hWnd,%frmName_txtAge,strAge)
                                    strPerson="Your Name Is " & strFirstName & " " & strLastName & " And You Are " & strAge & " Years Old."
                                    Call SetWindowText(GetDlgItem(Wea.hWnd,%frmName_txtPerson),Byval Strptr(strPerson))
                                  End Sub
                                  
                                  
                                  Function fnWndProc_OnCommand(Wea As WndEventArgs) As Long
                                    Select Case As Long Lowrd(Wea.wParam)
                                      Case %frmName_btnExecute
                                        Select Case As Long HiWrd(Wea.wParam)
                                          Case %BN_CLICKED
                                            Call frmName_btnExecute_Click(Wea)
                                        End Select
                                    End Select
                                  
                                    fnWndProc_OnCommand=0
                                  End Function
                                  
                                  
                                  Function fnWndProc_OnClose(Wea As WndEventArgs) As Long
                                    Call PostQuitMessage(0)
                                    fnWndProc_OnClose=0
                                  End Function
                                  
                                  
                                  Function fnWndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long
                                    Local Wea As WndEventArgs
                                    Register iReturn As Long
                                    Register i As Long
                                  
                                    For i=0 To 2
                                      If wMsg=MsgHdlr(i).wMessage Then
                                         Wea.hWnd=hWnd: Wea.wParam=wParam: Wea.lParam=lParam
                                         Call Dword MsgHdlr(i).dwFnPtr Using FnPtr(Wea) To iReturn
                                         fnWndProc=iReturn
                                         Exit Function
                                      End If
                                    Next i
                                  
                                    fnWndProc=DefWindowProc(hWnd,wMsg,wParam,lParam)
                                  End Function
                                  
                                  
                                  Sub AttachMessageHandlers()
                                    ReDim MsgHdlr(2) As MessageHandler  'Associate Windows Message With Message Handlers
                                    MsgHdlr(0).wMessage=%WM_CREATE   :   MsgHdlr(0).dwFnPtr=CodePtr(fnWndProc_OnCreate)
                                    MsgHdlr(1).wMessage=%WM_COMMAND  :   MsgHdlr(1).dwFnPtr=CodePtr(fnWndProc_OnCommand)
                                    MsgHdlr(2).wMessage=%WM_CLOSE    :   MsgHdlr(2).dwFnPtr=CodePtr(fnWndProc_OnClose)
                                  End Sub
                                  
                                  
                                  Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long
                                    Local szAppName As Asciiz * 16
                                    Local wc As WndClassEx
                                    Local hWnd As Dword
                                    Local Msg As tagMsg
                                  
                                    szAppName="prjName"                            :  Call AttachMessageHandlers()
                                    wc.lpszClassName=VarPtr(szAppName)             :  wc.lpfnWndProc=CodePtr(fnWndProc)
                                    wc.cbSize=SizeOf(wc)                           :  wc.style=%CS_HREDRAW Or %CS_VREDRAW
                                    wc.cbClsExtra=0                                :  wc.cbWndExtra=0
                                    wc.hInstance=hIns                              :  wc.hIcon=LoadIcon(%NULL, ByVal %IDI_APPLICATION)
                                    wc.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW) :  wc.hbrBackground=%COLOR_BTNFACE+1
                                    wc.lpszMenuName=%NULL
                                    Call RegisterClassEx(wc)
                                    hWnd=CreateWindow(szAppName,"Enter Your Name And Age",%WS_OVERLAPPEDWINDOW,200,100,396,192,0,0,hIns,ByVal 0)
                                    Call ShowWindow(hWnd,iShow)
                                    While GetMessage(Msg,%NULL,0,0)
                                      Call TranslateMessage(Msg)
                                      Call DispatchMessage(Msg)
                                    Wend
                                  
                                    Function=msg.wParam
                                  End Function
                                  Fred
                                  "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                                  Comment


                                  • #18
                                    Fred, good work!

                                    I was able to follow it through, once I realised that we are using more or less the same language, I use DDT and PB Windows, fortunately I do have a PBCC compiler also!

                                    Did not understand why you used local variables for the GETTEXT results instead of the functions themselves returning strings, do you need to refer to those variables again?

                                    Reagrding the parser, what would you expect out of this VB string?

                                    "Q" & myfunc(a$, "X", int(0.5 + (b!/2)))

                                    PS I meant Right Hand Side - real tech-speak, no?

                                    Comment


                                    • #19
                                      what would you expect out of this VB string?

                                      "Q" & myfunc(a$, "X", int(0.5 + (b!/2)))
                                      I would expect that I'd wish somebody would create a converter so I didn't have to figure it all out again!

                                      Do we all have both compilers?

                                      Rod
                                      Rod
                                      In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                                      Comment


                                      • #20
                                        Oh! RHS! Good, we'll go with that!

                                        On my long walk up the mountain today it occurred to me the function could have returned the string through a return value instead of through a parameter, but for some reason I seem to do things obscurely sometimes. If that works that way why don't we change it so as to have strGetWindowText() function instead of pbGetWindowText() Sub?

                                        A snafu occurred to me regarding the parser function too. As your myfunc(a$, "X", int(0.5 + (b!/2))) indicates, functions can also contain literal string parameters, and that is a sorry fact for us. In other words, this too could be in a literal string parameter -- "Frank & Charlie". And I believe that could wreck parser logic too. And while there might be others, this occurred to me also...

                                        txtAmountOwed.Text = "Your Total Bill Comes To " & Format(curAmountOwed, "###,###.00")

                                        So that's something else to think about. I even believe '&' symbols might be in some of the symbols Format's string uses to specify how to format the value. All this leads me to wonder if some other basis might be used to parse the string instead of using '&' or '+' symbols as separators. Perhaps it might come down to doing an InStr() against every symbol in the symbol table plus all reserved words that at some point we're going to have to store. I hope it doesn't, but I'm fearing it could get ugly.

                                        Probably the next thing to move onto would be functions that return strings, as we are discussing. After that I'd like to try arrays and what Visual Basic terms "Control Arrays". I used control arrays very heavily in my VB programming - mostly arrays of text boxes or buttons. For text boxes it would look like this...

                                        txtData(0).Text
                                        txtData(1).Text
                                        ...
                                        ...
                                        ...
                                        txtData(n).Text

                                        But, I've a lot to do before I get to that. By the way, I got the CCParse.bas program (the Console Compiler one) outputting the exact function as in the code I posted yesterday using the procedure described. In other words, creating the four local strings, calling pbGetWindowText() 3 times to get the data out of the text boxes, then putting the resulting string in the txtPerson text box. I need yet to transfer that code over to the GUI converter program to write the whole source code file.

                                        I'd like to make it clear that all this code I'm writing is just to flush out hopefully all the difficulties and issues. I think after we fully understand the issues and qwagmires, only then will we be able to start writing 'real' code.

                                        It occurred to me not everyone may have the console compiler. For those that don't I'd think a search and replace on all the Print statements to add a #FileNum, then output the data to a text file would work. You could then close the file and immediately Shell or ShellExecute the file.
                                        Fred
                                        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                                        Comment

                                        Working...
                                        X