VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX" Begin VB.Form frmProc Caption = "Procedimientos" ClientHeight = 4650 ClientLeft = 1185 ClientTop = 960 ClientWidth = 9435 Icon = "Proc.frx":0000 KeyPreview = -1 'True LinkTopic = "Form1" MDIChild = -1 'True ScaleHeight = 4650 ScaleWidth = 9435 Begin RichTextLib.RichTextBox txtEditor Height = 3495 Left = 0 TabIndex = 4 Top = 720 Width = 9375 _ExtentX = 16536 _ExtentY = 6165 _Version = 393217 ScrollBars = 3 DisableNoScroll = -1 'True RightMargin = 9,99999e5 TextRTF = $"Proc.frx":0E42 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 960 Top = 1320 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin MSComctlLib.TabStrip TabStrip1 Height = 375 Left = 0 TabIndex = 2 TabStop = 0 'False Top = 360 Width = 9375 _ExtentX = 16536 _ExtentY = 661 HotTracking = -1 'True Separators = -1 'True TabMinWidth = 1764 _Version = 393216 BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} NumTabs = 1 BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} ImageVarType = 2 EndProperty EndProperty End Begin MSComctlLib.ImageList ImageList1 Left = 240 Top = 1200 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 393216 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 7 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":0EF0 Key = "NUEVO" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":104A Key = "BORRAR" EndProperty BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":11A4 Key = "MODIF" EndProperty BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":12FE Key = "MODULOS" EndProperty BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":1458 Key = "IMPEXP" EndProperty BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":22AA Key = "IZQ" EndProperty BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Proc.frx":30FC Key = "DER" EndProperty EndProperty End Begin MSComctlLib.Toolbar Toolbar1 Align = 1 'Align Top Height = 330 Left = 0 TabIndex = 3 Top = 0 Width = 9435 _ExtentX = 16642 _ExtentY = 582 ButtonWidth = 2064 ButtonHeight = 582 AllowCustomize = 0 'False Wrappable = 0 'False Style = 1 TextAlignment = 1 ImageList = "ImageList1" _Version = 393216 BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} NumButtons = 14 BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "&Nuevo" Key = "NUEVO" Object.ToolTipText = "Nuevo módulo" ImageKey = "NUEVO" EndProperty BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "N&ombre" Key = "MODIF" Object.ToolTipText = "Cambiar nombre" ImageKey = "MODIF" EndProperty BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "&Borrar" Key = "BORRAR" Object.ToolTipText = "Borrar módulo" ImageKey = "BORRAR" EndProperty BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "&Imp./exp." Key = "IMPEXP" Object.ToolTipText = "Importar/exportar módulo" ImageKey = "IMPEXP" Style = 5 BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628} NumButtonMenus = 3 BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628} Key = "IMP_MODULO" Text = "Importar módulo" EndProperty BeginProperty ButtonMenu2 {66833FEE-8583-11D1-B16A-00C0F0283628} Key = "EXP_MODULO" Text = "Exportar módulo" EndProperty BeginProperty ButtonMenu3 {66833FEE-8583-11D1-B16A-00C0F0283628} Key = "SUST_MODULO" Text = "Sustituir módulo" EndProperty EndProperty EndProperty BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "&Módulos" Key = "MODULOS" Object.ToolTipText = "Lista de módulos" ImageKey = "MODULOS" Style = 5 BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628} NumButtonMenus = 3 BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628} Text = "Módulo 1" EndProperty BeginProperty ButtonMenu2 {66833FEE-8583-11D1-B16A-00C0F0283628} Text = "Módulo 2" EndProperty BeginProperty ButtonMenu3 {66833FEE-8583-11D1-B16A-00C0F0283628} Text = "Módulo 3" EndProperty EndProperty EndProperty BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "Mov. iz&q." Key = "IZQ" Object.ToolTipText = "Mover módulo hacia la izquierda" ImageKey = "IZQ" EndProperty BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} Caption = "Mov. &der." Key = "DER" Object.ToolTipText = "Mover módulo hacia la derecha" ImageKey = "DER" Object.Width = 1e-4 EndProperty BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty EndProperty End Begin VB.ComboBox lstProc Height = 315 Left = 2040 Style = 2 'Dropdown List TabIndex = 1 TabStop = 0 'False Top = 4320 Width = 3375 End Begin MSComctlLib.StatusBar StatusBar1 Align = 2 'Align Bottom Height = 375 Left = 0 TabIndex = 0 Top = 4275 Width = 9435 _ExtentX = 16642 _ExtentY = 661 _Version = 393216 BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} NumPanels = 3 BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} Object.Width = 1764 MinWidth = 1764 Text = "Lin: 1" TextSave = "Lin: 1" Key = "Lin" EndProperty BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} Object.Width = 1764 MinWidth = 1764 Text = "Col: 1" TextSave = "Col: 1" Key = "Col" EndProperty BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} AutoSize = 1 Object.Width = 12541 EndProperty EndProperty End End Attribute VB_Name = "frmProc" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Type PosEd PrimeraLinea As Long CarCursor As Long End Type Private lLinProc() As Long ' para guardar la línea de inicio de cada procedimiento Private bElimTecla As Boolean ' si hay que interceptar y eliminar la última tecla pulsada Private lUltTab As Long ' última pestaña sobre la que hemos pulsado Private LinTab() As PosEd ' guarda la línea en la que se ha quedado el cursor dentro de un módulo Private Sub lstProc_Click() Dim lLin As Long If lstProc.ListIndex >= 0 Then lLin = lLinProc(lstProc.ListIndex) IrALineaTextbox txtEditor, lLin txtEditor.Refresh txtEditor.SetFocus End If End Sub Private Sub lstProc_DropDown() Dim bCambio As Boolean Dim s As String Dim i As Long, lLin As Long Screen.MousePointer = vbHourglass LockWindowUpdate lstProc.hwnd lstProc.Clear ' recorremos las líneas del Textbox buscando CMD_SUB y añadiendo ' el nombre del procedimiento a la lista y el número de línea inicial lLin = 0 ReDim lLinProc(0) For i = 0 To NumLineasTextbox(txtEditor) s = ContenidoLineaTextbox(txtEditor, i) s = Trim(s) If Left(UCase(s), Len(CMD_SUB)) = CMD_SUB Then lstProc.AddItem Right(s, Len(s) - Len(CMD_SUB)) ReDim Preserve lLinProc(lLin) lLinProc(lLin) = i lLin = lLin + 1 End If Next ' ordenamos la lista (método de la burbuja) Do bCambio = False For i = 0 To lstProc.ListCount - 2 If lstProc.List(i) > lstProc.List(i + 1) Then bCambio = True s = lstProc.List(i) lLin = lLinProc(i) lstProc.List(i) = lstProc.List(i + 1) lstProc.List(i + 1) = s lLinProc(i) = lLinProc(i + 1) lLinProc(i + 1) = lLin End If Next Loop While bCambio LockWindowUpdate 0 Screen.MousePointer = vbDefault End Sub Private Sub Form_Activate() ActivarMenuEdicion End Sub Private Sub Form_Deactivate() DesactivarMenuEdicion GuardarMod End Sub Private Sub Form_Load() bElimTecla = False txtEditor.Font.Name = sEdLetra txtEditor.Font.Size = lEdTamLetra lUltTab = 0 ActivarMenuEdicion txtEditor.Text = "" ' carga la pantalla de búsqueda Load frmBuscar If Not bHayModulos Then NuevoMod "" End If CreaFichas CargarMod End Sub Private Sub Form_LostFocus() GuardarMod End Sub Private Sub Form_Resize() Dim i As Integer On Error Resume Next TabStrip1.Width = Me.ScaleWidth txtEditor.Width = Me.ScaleWidth txtEditor.Height = Me.ScaleHeight - Toolbar1.Height - TabStrip1.Height - StatusBar1.Height lstProc.Top = Toolbar1.Height + TabStrip1.Height + txtEditor.Height + 40 lstProc.Left = StatusBar1.Panels(3).Left + 30 End Sub Private Sub Form_Unload(Cancel As Integer) DesactivarMenuEdicion GuardarMod End Sub Private Sub ActivarMenuEdicion() Dim i As Integer For i = 0 To frmPrincipal.mEdicion.Count - 1 If frmPrincipal.mEdicion(i).Caption <> "-" Then frmPrincipal.mEdicion(i).Enabled = True End If Next frmPrincipal.Toolbar1.Buttons("CORTAR").Enabled = True frmPrincipal.Toolbar1.Buttons("COPIAR").Enabled = True frmPrincipal.Toolbar1.Buttons("PEGAR").Enabled = True frmPrincipal.Toolbar1.Buttons("BUSCAR").Enabled = True End Sub Private Sub DesactivarMenuEdicion() Dim i As Integer For i = 0 To frmPrincipal.mEdicion.Count - 1 If frmPrincipal.mEdicion(i).Caption <> "-" Then frmPrincipal.mEdicion(i).Enabled = False End If Next frmPrincipal.Toolbar1.Buttons("CORTAR").Enabled = False frmPrincipal.Toolbar1.Buttons("COPIAR").Enabled = False frmPrincipal.Toolbar1.Buttons("PEGAR").Enabled = False frmPrincipal.Toolbar1.Buttons("BUSCAR").Enabled = False End Sub Private Sub TabStrip1_Click() Dim i As Long ' comprobamos si se pulsa sobre las misma pestaña i = TabStrip1.SelectedItem.index - 1 If i <> lUltTab Then GuardarMod If lUltTab >= 0 Then LinTab(lUltTab).PrimeraLinea = PrimeraLineaTextbox(txtEditor) LinTab(lUltTab).CarCursor = txtEditor.SelStart End If LockWindowUpdate txtEditor.hwnd CargarMod If txtEditor.Visible Then txtEditor.SetFocus End If lstProc.ListIndex = -1 lUltTab = i PosicionTextbox txtEditor, LinTab(lUltTab).PrimeraLinea, _ LinTab(lUltTab).CarCursor LockWindowUpdate 0 End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.key Case "NUEVO" NuevoMod "" Case "MODIF" ModifMod Case "BORRAR" BorrarMod Case "IZQ" MoverModIzq Case "DER" MoverModDer End Select End Sub Private Sub Toolbar1_ButtonDropDown(ByVal Button As MSComctlLib.Button) Dim i As Long If Button.key = "MODULOS" Then Button.ButtonMenus.Clear For i = 1 To TabStrip1.Tabs.Count Button.ButtonMenus.Add , , TabStrip1.Tabs(i).Caption Next End If End Sub Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu) Select Case ButtonMenu.Parent.key Case "MODULOS" Set TabStrip1.SelectedItem = TabStrip1.Tabs(ButtonMenu.index) Case "IMPEXP" Select Case ButtonMenu.key Case "EXP_MODULO" ExportarModulo Case "IMP_MODULO" ImportarModulo Case "SUST_MODULO" SustituirModulo End Select End Select End Sub Private Sub txtEditor_Click() EstadoEditor End Sub Private Sub txtEditor_KeyDown(KeyCode As Integer, Shift As Integer) Dim Lineas() As Long Dim bShiftTab As Boolean Dim iCol As Integer, iTab As Integer, iSpc As Integer Dim i As Long, lPos As Long, lLin As Long, lUltLin As Long If KeyCode = vbKeyTab Then bShiftTab = ((Shift And vbShiftMask) > 0) If txtEditor.SelLength > 0 Then ' primero construimos una lista de líneas modificar i = 0 lUltLin = -1 ReDim Lineas(0) For lPos = txtEditor.SelStart To txtEditor.SelStart + txtEditor.SelLength - 1 lLin = LineaCarTextbox(txtEditor, lPos) If lLin <> lUltLin Then ReDim Preserve Lineas(i) Lineas(i) = lLin i = i + 1 lUltLin = lLin End If Next ' recorremos las líneas seleccionadas añadiendo o quitando la tabulación For i = 0 To UBound(Lineas) txtEditor.SelStart = CarLineaTextbox(txtEditor, Lineas(i)) If bShiftTab Then txtEditor.SelLength = iEdAnchoTab ' si son todo espacios, los eliminamos todos ' si no, sólo los espacios hasta el primer caracter que no lo sea txtEditor.SelText = LTrim(txtEditor.SelText) Else txtEditor.SelLength = 0 txtEditor.SelText = Space(iEdAnchoTab) End If Next ' dejamos el bloque seleccionado txtEditor.SelStart = CarLineaTextbox(txtEditor, Lineas(0)) txtEditor.SelLength = CarLineaTextbox(txtEditor, Lineas(UBound(Lineas))) _ - CarLineaTextbox(txtEditor, Lineas(0)) _ + Len(ContenidoLineaTextbox(txtEditor, Lineas(UBound(Lineas)))) Else If Not bShiftTab Then ' nos posicionamos en el siguiente múltiplo de 'iEdAnchoTab' ' NOTA: usamos división entera (\) para obtener el nº de tabulación actual iCol = ColumnaTextbox(txtEditor) iTab = ((iCol \ iEdAnchoTab) + 1) * iEdAnchoTab iSpc = iTab - iCol If iSpc > 0 Then txtEditor.SelText = Space(iSpc) End If End If End If bElimTecla = True End If End Sub Private Sub txtEditor_KeyPress(KeyAscii As Integer) ' interceptamos la última tecla pulsada If bElimTecla Then KeyAscii = 0 bElimTecla = False End If End Sub Private Sub EstadoEditor() StatusBar1.Panels("Lin").Text = "Lin: " & LineaTextbox(txtEditor) + 1 StatusBar1.Panels("Col").Text = "Col: " & ColumnaTextbox(txtEditor) + 1 End Sub Private Sub txtEditor_KeyUp(KeyCode As Integer, Shift As Integer) EstadoEditor End Sub Public Sub IrA() frmIrA.Show vbModal If frmIrA.lLin > 0 Then IrALineaTextbox txtEditor, frmIrA.lLin - 1 End If Unload frmIrA txtEditor.SetFocus End Sub ' carga el módulo actual Private Sub CargarMod() Dim F As New Win32File Dim i As Integer Dim c As String, sFich As String If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If i = TabStrip1.SelectedItem.index - 1 If i < 0 Then Exit Sub End If sFich = RutaFich(sFichAventura) & "\" & ListaMod(i).Fichero Screen.MousePointer = vbHourglass On Error GoTo Error_CargarMod2 txtEditor.Text = "" F.OpenFile sFich, True On Error GoTo Error_CargarMod1 c = Space(F.Size) F.ReadString c F.CloseFile txtEditor.Text = c Screen.MousePointer = vbDefault Exit Sub Error_CargarMod1: F.CloseFile Error_CargarMod2: txtEditor.Text = "" LockWindowUpdate 0 Screen.MousePointer = vbDefault MsgBox "Error al cargar módulo: " & Err.Description, vbOKOnly + vbCritical, "Cargar módulo" End Sub ' guarda el módulo actual, devuelve False si error Public Function GuardarMod() As Boolean Dim F As New Win32File Dim i As Long Dim c As String, sFich As String i = lUltTab If i < 0 Then GuardarMod = False Exit Function End If sFich = RutaFich(sFichAventura) & "\" & ListaMod(i).Fichero Screen.MousePointer = vbHourglass On Error GoTo Error_GuardarMod F.NewFile sFich F.WriteString txtEditor.Text F.CloseFile GuardarMod = True Screen.MousePointer = vbDefault Exit Function Error_GuardarMod: F.CloseFile GuardarMod = False Screen.MousePointer = vbDefault MsgBox "Error al guardar módulo: " & Err.Description, vbOKOnly + vbCritical, "Guardar módulo" End Function ' crea un nuevo módulo y lo añade a la lista, devuelve el nº del ' módulo creado dentro de la lista (-1 si error) ' el parámetro 'sNuevo' indica el nombre del nuevo módulo, si le pasamos ' una cadena vacía le da un nombre por defecto Private Function NuevoMod(ByVal sNuevo As String) As Long Dim bNuevo As Boolean Dim i As Long, j As Long Dim n As Integer, iFich As Integer Dim sNombre As String, sFich As String On Error GoTo Error_NuevoMod3 bNuevo = False If Not bHayModulos Then i = 0 ReDim ListaMod(0) ReDim LinTab(0) bHayModulos = True bNuevo = True Else i = UBound(ListaMod) + 1 ReDim Preserve ListaMod(i) ReDim Preserve LinTab(i) End If On Error GoTo Error_NuevoMod2 ' descripción If sNuevo = "" Then sNombre = "" Else sNombre = sNuevo End If ' nombre de fichero ' probamos con el número correlativo sFich = sFichAventura & Format(i, "0000") & EXT_SCR If ExisteFichero(sFich) Then ' si no pudo ser el número correlativo hay que buscar uno For j = 0 To 9999 sFich = sFichAventura & Format(j, "0000") & EXT_SCR If Not ExisteFichero(sFich) Then Exit For End If Next End If ListaMod(i).Nombre = sNombre ListaMod(i).Fichero = NombreFich(sFich) iFich = FreeFile Open sFich For Output As #iFich On Error GoTo Error_NuevoMod1 Print #iFich, ""; Close #iFich If GuardarModulos(sFichAventura & EXT_PROC) Then If bNuevo Then TabStrip1.Tabs(1).Caption = sNombre Else TabStrip1.Tabs.Add , , sNombre End If Set TabStrip1.SelectedItem = TabStrip1.Tabs(TabStrip1.Tabs.Count) Else GoTo Error_NuevoMod2 End If NuevoMod = i Exit Function Error_NuevoMod1: Close #iFich Error_NuevoMod2: ' dejamos las cosas como estaban If bNuevo Then bHayModulos = False ReDim ListaMod(0) Else i = UBound(ListaMod) i = i - 1 If i < 0 Then i = 0 End If ReDim Preserve ListaMod(i) End If Error_NuevoMod3: MsgBox "Error al crear el módulo.", vbOKOnly + vbCritical, "Nuevo módulo" NuevoMod = -1 End Function ' crea las pestañas necesarias Private Sub CreaFichas() Dim i As Long lUltTab = 0 TabStrip1.Tabs.Clear If Not bHayModulos Then ReDim LinTab(0) Exit Sub End If For i = 0 To UBound(ListaMod) TabStrip1.Tabs.Add , , ListaMod(i).Nombre Next ReDim LinTab(UBound(ListaMod)) Set TabStrip1.SelectedItem = TabStrip1.Tabs(1) End Sub ' cambia el nombre de un módulo Private Sub ModifMod() Dim bExiste As Boolean Dim s As String Dim i As Long If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If Do While True s = InputBox("Modificar nombre de módulo", "Introduce el nuevo nombre del módulo", "") If s = "" Then Exit Sub Else ' comprobamos si ya existe uno igual bExiste = False For i = 1 To TabStrip1.Tabs.Count If UCase(s) = UCase(TabStrip1.Tabs(i).Caption) Then MsgBox "Ya existe un módulo con ese nombre.", vbOKOnly + vbExclamation, _ "Nombre de módulo repetido" bExiste = True Exit For End If Next If Not bExiste Then TabStrip1.SelectedItem.Caption = s ListaMod(TabStrip1.SelectedItem.index - 1).Nombre = s Exit Sub End If End If Loop End Sub ' borra un módulo Private Sub BorrarMod() Dim iOpc As Integer Dim i As Long, j As Long Dim sFich As String If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If iOpc = MsgBox("Se va a borrar el módulo " & TabStrip1.SelectedItem.Caption & _ ". ¿Quieres continuar?", vbYesNo + vbQuestion, "Borrar módulo") If iOpc <> vbYes Then Exit Sub End If ' borramos el módulo On Error Resume Next i = TabStrip1.SelectedItem.index - 1 sFich = ListaMod(i).Fichero Kill RutaFich(sFichAventura) & "\" & sFich For j = i To UBound(ListaMod) - 1 ListaMod(j) = ListaMod(j + 1) Next i = UBound(ListaMod) - 1 If i < 0 Then txtEditor.Text = "" ReDim ListaMod(0) bHayModulos = False NuevoMod "" Else ReDim Preserve ListaMod(i) End If CreaFichas CargarMod ' tenemos que forzar que guarde al salir para evitar que ' si sale sin guardar se quede la referencia al módulo ' pero el fichero ha sido borrado frmPrincipal.bFuerzaGuardar = True End Sub ' exporta el módulo actual Private Sub ExportarModulo() Dim F As New Win32File Dim i As Integer, iOpc As Integer Dim c As String, sFich As String ' cogemos el índice del módulo actual If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If i = TabStrip1.SelectedItem.index - 1 If i < 0 Then Exit Sub End If ' nombre del módulo actual sFich = ListaMod(i).Nombre CommonDialog1.DialogTitle = "Exportar módulo" CommonDialog1.Filter = "Módulos de Visual SINTAC|*" & EXT_MOD & "|Todos los archivos|*.*" CommonDialog1.InitDir = App.Path CommonDialog1.Flags = cdlOFNPathMustExist Or cdlOFNHideReadOnly Or cdlOFNNoReadOnlyReturn CommonDialog1.CancelError = True CommonDialog1.fileName = sFich On Error Resume Next CommonDialog1.ShowOpen If Err.Number <> 0 Then Exit Sub End If sFich = CommonDialog1.fileName ' comprobamos si el fichero ya existe If ExisteFichero(sFich) Then iOpc = MsgBox("El fichero ya existe. ¿Quieres sobreescribirlo?", vbYesNo + vbQuestion, "Exportar módulo") If iOpc <> vbYes Then Exit Sub End If End If Screen.MousePointer = vbHourglass On Error GoTo Error_ExportarModulo F.NewFile sFich F.WriteString txtEditor.Text F.CloseFile Screen.MousePointer = vbDefault MsgBox "El módulo ha sido exportado correctamente.", vbOKOnly + vbInformation, "Exportar módulo" Exit Sub Error_ExportarModulo: F.CloseFile Screen.MousePointer = vbDefault MsgBox "Error al exportar módulo: " & Err.Description, vbOKOnly + vbCritical, "Exportar módulo" End Sub ' importa un módulo Private Sub ImportarModulo() Dim sFich As String, sFichMod As String Dim lMod As Long CommonDialog1.DialogTitle = "Importar módulo" CommonDialog1.Filter = "Módulos de Visual SINTAC|*" & EXT_MOD & "|Todos los archivos|*.*" CommonDialog1.InitDir = App.Path CommonDialog1.Flags = cdlOFNFileMustExist Or cdlOFNPathMustExist Or cdlOFNHideReadOnly CommonDialog1.CancelError = True CommonDialog1.fileName = "" On Error Resume Next CommonDialog1.ShowOpen If Err.Number <> 0 Then Exit Sub End If sFich = CommonDialog1.fileName On Error GoTo Error_ImportarModulo Screen.MousePointer = vbHourglass ' creamos un nuevo módulo lMod = NuevoMod("") If lMod <> -1 Then sFichMod = RutaFich(sFichAventura) & "\" & ListaMod(lMod).Fichero ' copiamos el fichero que queremos importar sobre el del módulo FileCopy sFich, sFichMod ' cargamos el módulo CargarMod End If Screen.MousePointer = vbDefault MsgBox "El módulo se ha importado correctamente.", vbOKOnly + vbInformation, "Importar módulo" Exit Sub Error_ImportarModulo: Screen.MousePointer = vbDefault MsgBox "Error al importar módulo: " & Err.Description, vbOKOnly + vbCritical, "Importar módulo" End Sub ' sustituye un módulo Private Sub SustituirModulo() Dim sFich As String, sFichMod As String Dim lMod As Long Dim iOpc As Integer iOpc = MsgBox("Se va a sustituir el módulo actual. ¿Quieres continuar?", _ vbYesNo + vbQuestion, "Sustituir módulo") If iOpc <> vbYes Then Exit Sub End If ' cogemos el índice del módulo actual If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If lMod = TabStrip1.SelectedItem.index - 1 If lMod < 0 Then Exit Sub End If CommonDialog1.DialogTitle = "Sustituir módulo" CommonDialog1.Filter = "Módulos de Visual SINTAC|*" & EXT_MOD & "|Todos los archivos|*.*" CommonDialog1.InitDir = App.Path CommonDialog1.Flags = cdlOFNFileMustExist Or cdlOFNPathMustExist Or cdlOFNHideReadOnly CommonDialog1.CancelError = True CommonDialog1.fileName = "" On Error Resume Next CommonDialog1.ShowOpen If Err.Number <> 0 Then Exit Sub End If sFich = CommonDialog1.fileName On Error GoTo Error_SustituirModulo Screen.MousePointer = vbHourglass sFichMod = RutaFich(sFichAventura) & "\" & ListaMod(lMod).Fichero ' copiamos el fichero que queremos importar sobre el del módulo FileCopy sFich, sFichMod ' cargamos el módulo CargarMod Screen.MousePointer = vbDefault MsgBox "El módulo se ha sustituido correctamente.", vbOKOnly + vbInformation, "Importar módulo" Exit Sub Error_SustituirModulo: Screen.MousePointer = vbDefault MsgBox "Error al sustituir módulo: " & Err.Description, vbOKOnly + vbCritical, "Importar módulo" End Sub ' mueve un módulo hacia la izquierda Private Sub MoverModIzq() Dim M As Modulo Dim s As String Dim i As Long ' cogemos el índice del módulo actual If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If i = TabStrip1.SelectedItem.index - 1 If i < 0 Then Exit Sub End If If i > 0 And UBound(ListaMod) > 0 Then M = ListaMod(i - 1) ListaMod(i - 1) = ListaMod(i) ListaMod(i) = M i = i + 1 s = TabStrip1.Tabs(i - 1).Caption TabStrip1.Tabs(i - 1).Caption = TabStrip1.Tabs(i).Caption TabStrip1.Tabs(i).Caption = s CargarMod Set TabStrip1.SelectedItem = TabStrip1.Tabs(i - 1) End If End Sub ' mueve un módulo hacia la derecha Private Sub MoverModDer() Dim M As Modulo Dim s As String Dim i As Long ' cogemos el índice del módulo actual If TabStrip1.SelectedItem Is Nothing Then Exit Sub End If i = TabStrip1.SelectedItem.index - 1 If i < 0 Then Exit Sub End If If i < UBound(ListaMod) And UBound(ListaMod) > 0 Then M = ListaMod(i + 1) ListaMod(i + 1) = ListaMod(i) ListaMod(i) = M i = i + 1 s = TabStrip1.Tabs(i + 1).Caption TabStrip1.Tabs(i + 1).Caption = TabStrip1.Tabs(i).Caption TabStrip1.Tabs(i).Caption = s CargarMod Set TabStrip1.SelectedItem = TabStrip1.Tabs(i + 1) End If End Sub