gambas-source-code/app/examples/Image/Lighttable/.src/FRename.class
Benoît Minisini c6a9cd69c2 [EXAMPLES]
* NEW: Add examples again. I hope correctly this time.


git-svn-id: svn://localhost/gambas/trunk@6726 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-12-12 19:58:52 +00:00

58 lines
1 KiB
Text

' Gambas class file
Private sOldName As String
Public Sub Form_Open()
txtRename.Text = Me.Tag
sOldName = Me.Tag
MarkFilename
End
Public Sub MarkFilename()
Dim lentext, posp As Integer
Dim right3 As String
right3 = Right$(txtRename.Text, 3)
lentext = Len(txtRename.Text)
If right3 = "jpg" Or right3 = "JPG" Then
posp = lentext - 4
Else
posp = lentext - 5
Endif
Me.SetFocus
txtRename.SetFocus
txtRename.Select(0, posp)
End
Public Sub btnCancel_Click()
Me.Close
End
Public Sub btnOK_Click()
Dim sNewName As String
sNewName = txtRename.Text
If sOldName = sNewName Then
Message.Error(("Old and new filename are identical."))
MarkFilename
Return
Endif
If FMain.TestRenameOne(sOldName, sNewName) = False Then ' if name already exists, cancel
txtRename.Text = sOldName
MarkFilename
Return
Endif
FMain.FileRename(sOldName, sNewName)
If FMain.Tag = "alpha" Then ' if sorted alphabetically, sort anew
FMain.mnuSortA_Click
Endif
Me.Close
End