A veces nos podemos preguntar cuantos recursos usa nuestra aplicación...
especialmente cuanto usa de memoria ram....
pues bien hagamos esto, cerremos la ide gambas y todos los proyectos o aplicaciones hechas con gambas.
Ahora abrimos solo nuestra aplicación antes instalada.
abrimos cualquier aplicación que muestre los procesos y buscamos esta palabra
"gbr3"
aquí un ejemplo como lo hice en mint mate con monitor de sistema.
La aplicación <Taller2015 versión 0.2.9> usa aproximadamente 20 megas de memoria ram.
también podemos obtener el nombre del programa y donde se encuentra instalado el ejecutable.
Allanando el camino a los iniciados en Gambas, porque programar en Gambas es un placer!!
miércoles, 23 de diciembre de 2015
jueves, 29 de octubre de 2015
Taller 2015
¿Eres reparador de computadoras y equipos informáticos y te hace falta un software que te ayude en tus tareas diarias?
Entones Taller2015 te ayudará.
Página de descargas: https://sourceforge.net/projects/taller2015/
lunes, 26 de octubre de 2015
Módulo CSV ( Importar/Exportar )
Con esto de que estoy trabajando con programas que manejan base de datos y por lógica tablas me veo obligado a programar módulos o clases pues son operaciones repetitivas como la de generar un archivo con formato csv de una tabla X.
Aqui les dejo la parte de exportar... jaja a ver si me sale la de importar.
Espero que les sirva para experimentar y probar..... hagan sus comentarios si lo desean. Saludos.
' gambas module file
' by postapase
Public Sub Exportar(coneccion As Connection, tabla As Table)
Dim Resultado As Result
Dim Ruta, Lista As String
Dim Campo As Field
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
Ruta = Dialog.Path &/ tabla.Name & ".csv"
Print Ruta
Resultado = coneccion.Exec("Select * From " & tabla.Name)
Do While Resultado.Available
For Each Campo In tabla.Fields
Lista &= "\"" & Resultado[Campo.Name] & "\","
Next
Resultado.MoveNext
Lista = Left$(Lista, Len(Lista) - 1) ' elimina la última coma que sobra
Lista &= gb.NewLine
Loop
File.Save(Ruta, Lista)
End
Public Sub Importar()
' pendiente....
End
' by postapase
Public Sub Exportar(coneccion As Connection, tabla As Table)
Dim Resultado As Result
Dim Ruta, Lista As String
Dim Campo As Field
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
Ruta = Dialog.Path &/ tabla.Name & ".csv"
Print Ruta
Resultado = coneccion.Exec("Select * From " & tabla.Name)
Do While Resultado.Available
For Each Campo In tabla.Fields
Lista &= "\"" & Resultado[Campo.Name] & "\","
Next
Resultado.MoveNext
Lista = Left$(Lista, Len(Lista) - 1) ' elimina la última coma que sobra
Lista &= gb.NewLine
Loop
File.Save(Ruta, Lista)
End
Public Sub Importar()
' pendiente....
End
Llamada al módulo:
Public Sub btnCSVExport_Click()
Dim tabla As Table
tabla = FMain.Conectar1.Tables["deudas"]
CSV.Exportar(FMain.Conectar1, tabla)
End
Dim tabla As Table
tabla = FMain.Conectar1.Tables["deudas"]
CSV.Exportar(FMain.Conectar1, tabla)
End
Código Completo importar/exportar
' gambas module file
' by postapase (modulo CSV para tabla deudas)
Public Sub Exportar(coneccion As Connection, tabla As Table, dir As String) As Boolean
Dim Resultado As Result
Dim Ruta, Lista As String
Dim Campo As Field
Ruta = dir &/ tabla.Name & ".csv"
Resultado = coneccion.Exec("Select * From " & tabla.Name)
Do While Resultado.Available
For Each Campo In tabla.Fields
Lista &= "\"" & Resultado[Campo.Name] & "\","
Next
Resultado.MoveNext
Lista = Left$(Lista, Len(Lista) - 1) ' elimina la última coma que sobra
Lista &= gb.NewLine
Loop
If Exist(Ruta) Then
Kill Ruta
Wait 0.1
File.Save(Ruta, Lista)
Else
File.Save(Ruta, Lista)
Endif
If Exist(ruta) Then
Return True
Else
Return False
Endif
End
Public Sub Importar(coneccion As Connection, tabla As Table, ruta As String)
Dim Campo As Field
Dim ListaCampos, EsteCampo, ValoresFila, SQL As String
Dim CSV As File
Dim Separados As String[]
Dim FechaIngreso As Date
Dim FechaTermino As Date
Dim EsteMonto, EstaEntrega, EsteSaldo As Integer
Dim Estado As Boolean
Dim EsteMotivo As String
Dim EstaEvolucion As String
For Each Campo In tabla.Fields
ListaCampos &= "\"" & Campo.Name & "\","
Next
ListaCampos = Left$(ListaCampos, Len(ListaCampos) - 1)
coneccion.Delete(tabla.Name)
coneccion.Exec("update sqlite_sequence set seq = 0 Where name =&1", tabla.Name)
CSV = Open ruta For Read
While Not Eof(CSV)
Line Input #CSV, ValoresFila
Separados = Split(ValoresFila)
FechaIngreso = CDate(Replace$(Separados[1], "\"", ""))
EsteMonto = CInteger(Replace$(Separados[2], "\"", ""))
EstaEntrega = CInteger(Replace$(Separados[3], "\"", ""))
EsteSaldo = CInteger(Replace$(Separados[4], "\"", ""))
EsteMotivo = Replace$(Separados[5], "\"", "")
EstaEvolucion = Replace$(Separados[6], "\"", "")
FechaTermino = CDate(Replace$(Separados[7], "\"", ""))
Estado = CBoolean(Replace$(Separados[8], "\"", ""))
SQL = "insert into \"" & tabla.Name & "\" (" & ListaCampos & ") values (&1,&2,&3,&4,&5,&6,&7,&8,&9)"
Print SQL
Try coneccion.Exec(SQL, Null, FechaIngreso, EsteMonto, EstaEntrega, EsteSaldo, EsteMotivo, EstaEvolucion, FechaTermino, Estado)
If Error Then
Print Error.Text
Print Error.Where
Print Error.Code
Endif
Wend
Close #CSV
Deudas.MostrarDeudas()
End
' by postapase (modulo CSV para tabla deudas)
Public Sub Exportar(coneccion As Connection, tabla As Table, dir As String) As Boolean
Dim Resultado As Result
Dim Ruta, Lista As String
Dim Campo As Field
Ruta = dir &/ tabla.Name & ".csv"
Resultado = coneccion.Exec("Select * From " & tabla.Name)
Do While Resultado.Available
For Each Campo In tabla.Fields
Lista &= "\"" & Resultado[Campo.Name] & "\","
Next
Resultado.MoveNext
Lista = Left$(Lista, Len(Lista) - 1) ' elimina la última coma que sobra
Lista &= gb.NewLine
Loop
If Exist(Ruta) Then
Kill Ruta
Wait 0.1
File.Save(Ruta, Lista)
Else
File.Save(Ruta, Lista)
Endif
If Exist(ruta) Then
Return True
Else
Return False
Endif
End
Public Sub Importar(coneccion As Connection, tabla As Table, ruta As String)
Dim Campo As Field
Dim ListaCampos, EsteCampo, ValoresFila, SQL As String
Dim CSV As File
Dim Separados As String[]
Dim FechaIngreso As Date
Dim FechaTermino As Date
Dim EsteMonto, EstaEntrega, EsteSaldo As Integer
Dim Estado As Boolean
Dim EsteMotivo As String
Dim EstaEvolucion As String
For Each Campo In tabla.Fields
ListaCampos &= "\"" & Campo.Name & "\","
Next
ListaCampos = Left$(ListaCampos, Len(ListaCampos) - 1)
coneccion.Delete(tabla.Name)
coneccion.Exec("update sqlite_sequence set seq = 0 Where name =&1", tabla.Name)
CSV = Open ruta For Read
While Not Eof(CSV)
Line Input #CSV, ValoresFila
Separados = Split(ValoresFila)
FechaIngreso = CDate(Replace$(Separados[1], "\"", ""))
EsteMonto = CInteger(Replace$(Separados[2], "\"", ""))
EstaEntrega = CInteger(Replace$(Separados[3], "\"", ""))
EsteSaldo = CInteger(Replace$(Separados[4], "\"", ""))
EsteMotivo = Replace$(Separados[5], "\"", "")
EstaEvolucion = Replace$(Separados[6], "\"", "")
FechaTermino = CDate(Replace$(Separados[7], "\"", ""))
Estado = CBoolean(Replace$(Separados[8], "\"", ""))
SQL = "insert into \"" & tabla.Name & "\" (" & ListaCampos & ") values (&1,&2,&3,&4,&5,&6,&7,&8,&9)"
Print SQL
Try coneccion.Exec(SQL, Null, FechaIngreso, EsteMonto, EstaEntrega, EsteSaldo, EsteMotivo, EstaEvolucion, FechaTermino, Estado)
If Error Then
Print Error.Text
Print Error.Where
Print Error.Code
Endif
Wend
Close #CSV
Deudas.MostrarDeudas()
End
Llamadas al módulo
Public Sub btnCSVExport_Click()
Dim tabla As Table
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
tabla = FMain.Conectar1.Tables["deudas"]
If CSV.Exportar(FMain.Conectar1, tabla, Dialog.Path) Then
Message.Info("Se respaldo correctamente" & gb.NewLine & Dialog.Path &/ tabla.Name & ".csv")
Else
Message.Error("No se pudo respaldar!")
Endif
End
Public Sub btnImportarCSV_Click()
Dim tabla As Table
Dialog.Filter = ["*.csv", "Archivos .csv"]
Dialog.Path = User.Home
If Dialog.OpenFile() Then Return
tabla = FMain.Conectar1.Tables["deudas"]
CSV.Importar(FMain.Conectar1, tabla, Dialog.Path)
End
Dim tabla As Table
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
tabla = FMain.Conectar1.Tables["deudas"]
If CSV.Exportar(FMain.Conectar1, tabla, Dialog.Path) Then
Message.Info("Se respaldo correctamente" & gb.NewLine & Dialog.Path &/ tabla.Name & ".csv")
Else
Message.Error("No se pudo respaldar!")
Endif
End
Public Sub btnImportarCSV_Click()
Dim tabla As Table
Dialog.Filter = ["*.csv", "Archivos .csv"]
Dialog.Path = User.Home
If Dialog.OpenFile() Then Return
tabla = FMain.Conectar1.Tables["deudas"]
CSV.Importar(FMain.Conectar1, tabla, Dialog.Path)
End
sábado, 17 de octubre de 2015
Ejemplo Clase Respaldo
FMain:
' gambas class file
Public Respaldo1 As Respaldo
Public Sub Form_Open()
Respaldo1 = New Respaldo(1, txtOrigen.Text, txtDestino.Text)
cbxMes.Index = 9
End
Public Sub Button2_Click()
Dialog.Path = User.Home
If Dialog.OpenFile() Then Return
txtOrigen.Text = Dialog.Path
End
Public Sub cbxPeriodo_Click()
Select Case cbxPeriodo.Index
Case 0
Respaldo1.Periodo = 1
Case 1
Respaldo1.Periodo = 2
Case 2
Respaldo1.Periodo = 3
Case 3
Respaldo1.Periodo = 7
Case 4
Respaldo1.Periodo = 15
Case 5
Respaldo1.Periodo = 30
End Select
End
Public Sub Button1_Click()
If Respaldo1.Verificar() Then
LabInfo.Text = "se efectuo el respaldo"
Else
LabInfo.Text = "No se realizo respaldo"
Endif
End
Public Sub Button3_Click()
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
txtDestino.Text = Dialog.Path
End
Public Sub Button4_Click()
Shell "stat " & txtOrigen.Text
End
Public Sub Button5_Click()
Shell "touch -a -m -t " & cbxAnios.Text & cbxMes.Text & txtDia.Text & "0000.00 " & txtOrigen.Text
End
Public Respaldo1 As Respaldo
Public Sub Form_Open()
Respaldo1 = New Respaldo(1, txtOrigen.Text, txtDestino.Text)
cbxMes.Index = 9
End
Public Sub Button2_Click()
Dialog.Path = User.Home
If Dialog.OpenFile() Then Return
txtOrigen.Text = Dialog.Path
End
Public Sub cbxPeriodo_Click()
Select Case cbxPeriodo.Index
Case 0
Respaldo1.Periodo = 1
Case 1
Respaldo1.Periodo = 2
Case 2
Respaldo1.Periodo = 3
Case 3
Respaldo1.Periodo = 7
Case 4
Respaldo1.Periodo = 15
Case 5
Respaldo1.Periodo = 30
End Select
End
Public Sub Button1_Click()
If Respaldo1.Verificar() Then
LabInfo.Text = "se efectuo el respaldo"
Else
LabInfo.Text = "No se realizo respaldo"
Endif
End
Public Sub Button3_Click()
Dialog.Path = User.Home
If Dialog.SelectDirectory() Then Return
txtDestino.Text = Dialog.Path
End
Public Sub Button4_Click()
Shell "stat " & txtOrigen.Text
End
Public Sub Button5_Click()
Shell "touch -a -m -t " & cbxAnios.Text & cbxMes.Text & txtDia.Text & "0000.00 " & txtOrigen.Text
End
Clase Respaldo:
' gambas class file
'by postapase (humilde aporte a la comunidad gambera)
Property Periodo As Byte ''1=un día,2=dos días, 3=tres días,7 una semana, 15 una quincena, 30 un mes
Property RutaOrigen As String '' Ruta completa del archivo a respaldar
Property RutaDestino As String '' Lugar donde se respaldara el archivo
Private $Periodo As Byte
Private $RutaOrigen As String
Private $RutaDestino As String
Private $Diferencia As Integer
Private $NameArchivo As String
Private $Rutafinal As String
Private $UltimaModificacion As Date
Public Sub _new(periodo As Byte, origen As String, destino As String) ''Periodo,Origen,Destino
$Periodo = periodo
$RutaOrigen = origen
$RutaDestino = destino
$NameArchivo = File.BaseName($RutaOrigen)
End
Private Function Periodo_Read() As Byte
Return $Periodo
End
Private Sub Periodo_Write(Value As Byte)
$Periodo = Value
End
Private Function RutaOrigen_Read() As String
Return $RutaOrigen
End
Private Sub RutaOrigen_Write(Value As String)
$RutaOrigen = Value
End
Private Function RutaDestino_Read() As String
Return $RutaDestino
End
Private Sub RutaDestino_Write(Value As String)
$RutaDestino = Value
End
Public Sub Respaldar()
If Exist($Rutafinal) Then
Kill $Rutafinal
Wait 0.2
Copy $RutaOrigen To $RutaFinal
Else
Copy $RutaOrigen To $RutaFinal
Endif
End
Public Sub Verificar() As Boolean
$Rutafinal = $RutaDestino &/ $NameArchivo & "_" & Replace$(CString(Date), "/", "-")
$UltimaModificacion = Stat($RutaOrigen).LastModified
$Diferencia = DateDiff($UltimaModificacion, Date, gb.Day) '
If $Diferencia >= $Periodo Then
Respaldar()
Return True
Else
Return False
Endif
End
'by postapase (humilde aporte a la comunidad gambera)
Property Periodo As Byte ''1=un día,2=dos días, 3=tres días,7 una semana, 15 una quincena, 30 un mes
Property RutaOrigen As String '' Ruta completa del archivo a respaldar
Property RutaDestino As String '' Lugar donde se respaldara el archivo
Private $Periodo As Byte
Private $RutaOrigen As String
Private $RutaDestino As String
Private $Diferencia As Integer
Private $NameArchivo As String
Private $Rutafinal As String
Private $UltimaModificacion As Date
Public Sub _new(periodo As Byte, origen As String, destino As String) ''Periodo,Origen,Destino
$Periodo = periodo
$RutaOrigen = origen
$RutaDestino = destino
$NameArchivo = File.BaseName($RutaOrigen)
End
Private Function Periodo_Read() As Byte
Return $Periodo
End
Private Sub Periodo_Write(Value As Byte)
$Periodo = Value
End
Private Function RutaOrigen_Read() As String
Return $RutaOrigen
End
Private Sub RutaOrigen_Write(Value As String)
$RutaOrigen = Value
End
Private Function RutaDestino_Read() As String
Return $RutaDestino
End
Private Sub RutaDestino_Write(Value As String)
$RutaDestino = Value
End
Public Sub Respaldar()
If Exist($Rutafinal) Then
Kill $Rutafinal
Wait 0.2
Copy $RutaOrigen To $RutaFinal
Else
Copy $RutaOrigen To $RutaFinal
Endif
End
Public Sub Verificar() As Boolean
$Rutafinal = $RutaDestino &/ $NameArchivo & "_" & Replace$(CString(Date), "/", "-")
$UltimaModificacion = Stat($RutaOrigen).LastModified
$Diferencia = DateDiff($UltimaModificacion, Date, gb.Day) '
If $Diferencia >= $Periodo Then
Respaldar()
Return True
Else
Return False
Endif
End
dropbox: Clase_Respaldo-0.1.tar.gz
Suscribirse a:
Entradas (Atom)






