[Gambas-user] frm2form 0.01

Nelson Ferraz nferraz at ...184...
Mon Jul 21 17:07:11 CEST 2003


> Thanks for helping out with this!  I noticed you had ClientHeight and 
> ClientWidth in there as non-translatables.  I was using those as the form's 
> height and width fields (since they're always in twips, which I can convert, 
> while ScaleHeight and ScaleWidth depend on the value of ScaleMode).  What are 
> you using for height and width presently?

Yup! I included the following translation, and now the form is properly
dimensioned:

                'Client(\w+)'   => '$1',

> Also, be careful, if you just match on Begin and End you may match 
> BeginProperty and EndProperty.  That's why I did the ^\s*End\s*$ thing etc.  

Thanks for the remark! I included a "\b" (word boundary) after the Begin
and end, so it won't match BeginProperty and EndProperty:

                'Begin\b'         => '{',
                'End\b'           => '}',

I'm removing everything between BeginProperty and EndProperty, since I'm
not sure how Gambas would treat it:

  # Last touches
  {
    local $/;
    # Remove BeginProperty...EndProperty entire region
    $output =~ s/BeginProperty.+?EndProperty//gs;
  }

> I also am not sure it's safe to match the VB form files case sensitively; I 
> know VB itself writes the stuff with consistent mixed case but I don't know 
> about any third party tools people may have used.

Hmmm... it's working by now, but we could include a /i modifier in the
regexps.

> > The resulting form still crashes Gambas; I'm trying to spot the error.
> > (Benoit, is it possible that Gambas raise an error, instead of simply
> > dying?)
> 
> Are you also creating a formname.class file?  It can be empty, but Gambas gets 
> mad if it doesn't find one (as in exits without error message.)

That was the problem! :)

> But my guess would be your lack of Move(x,y,w,h) for each object on the form. 

No, that's okay; I'm using VB's Top, Left, Width and Height properties,
and Gambas understand that.

Here's the latest version of the script. I've managed to convert a
relativelly complex form (attached), but I had to replace a scroll bar
with a button.

[]s

Nelson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vb2gb.pl
Type: text/x-perl
Size: 1815 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20030721/1fdb0a16/attachment.pl>
-------------- next part --------------
VERSION 5.00
Begin VB.Form Form8 
   ClientHeight    =   6510
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7350
   LinkTopic       =   "Form8"
   Picture         =   "frmattendance.frx":0000
   ScaleHeight     =   6510
   ScaleWidth      =   7350
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      BackColor       =   &H00FF0000&
      Height          =   6495
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7335
      Begin VB.Frame Frame2 
         Height          =   4695
         Left            =   120
         TabIndex        =   1
         Top             =   1680
         Width           =   7095
         Begin VB.Frame Frame3 
            Caption         =   "Attendance Roster"
            Height          =   3015
            Left            =   120
            TabIndex        =   12
            Top             =   1560
            Width           =   6855
            Begin VB.VScrollBar VScroll1 
               Height          =   2895
               Left            =   6600
               TabIndex        =   13
               Top             =   120
               Width           =   255
            End
         End
         Begin VB.TextBox Text1 
            Height          =   285
            Left            =   3120
            TabIndex        =   11
            Text            =   "MM/DD/YYYY"
            Top             =   1080
            Width           =   1215
         End
         Begin VB.ComboBox Combo1 
            Height          =   315
            Left            =   1320
            TabIndex        =   9
            Text            =   "CMPS 374"
            Top             =   600
            Width           =   1695
         End
         Begin VB.TextBox Text2 
            Height          =   285
            Left            =   1320
            TabIndex        =   4
            Text            =   "MM/DD/YYYY"
            Top             =   1080
            Width           =   1215
         End
         Begin VB.CommandButton Command2 
            Caption         =   "Get Attendance"
            Height          =   375
            Left            =   4920
            TabIndex        =   3
            Top             =   360
            Width           =   1455
         End
         Begin VB.CommandButton Command3 
            Caption         =   "Clear Form"
            Height          =   375
            Left            =   4920
            TabIndex        =   2
            Top             =   1080
            Width           =   1455
         End
         Begin VB.Label Label6 
            Alignment       =   2  'Center
            Caption         =   "To"
            Height          =   255
            Left            =   2400
            TabIndex        =   10
            Top             =   1080
            Width           =   735
         End
         Begin VB.Label Label3 
            Caption         =   "Class:"
            Height          =   255
            Left            =   120
            TabIndex        =   6
            Top             =   600
            Width           =   1335
         End
         Begin VB.Label Label4 
            Caption         =   "Date Range:"
            Height          =   255
            Left            =   120
            TabIndex        =   5
            Top             =   1080
            Width           =   1335
         End
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Security Level:  Faculty"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   720
         TabIndex        =   8
         Top             =   1320
         Width           =   5295
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Student Communicator and Tracker Attendance Menu"
         BeginProperty Font 
            Name            =   "Comic Sans MS"
            Size            =   20.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1215
         Left            =   480
         TabIndex        =   7
         Top             =   120
         Width           =   6015
      End
   End
End
Attribute VB_Name = "Form8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()

End Sub

Private Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)

End Sub


More information about the User mailing list