@Book{Metz2001, %clave identificadora
hyphenation = {spanish},
author = {Metz, Christian},
date = {2001},
keywords = {listar},
location = {Barcelona},
publisher = {Paidós},
title = {El significante imaginario},
creationdate = {2023-08-04T08:08:02},
owner = {alberto},
}
(30-08-2023, 00:34)alberto-moyano escribió: todas las plantillas en juego son muchísimos, de ahí mi duda de si no era una alternativa hacerlo directamente desde SQL (pero insisto, no sé siquiera si es posible).
CREATE VIEW "view_albums" AS SELECT
albums.idx AS idx,
albums.name AS name,
albums.year AS year,
artists.name AS artist
FROM albums
LEFT JOIN artists ON albums.artist=artists.idx
ORDER BY albums.idx,albums.name ASC;
Public con1 As New Connection '' Conexion a la base de datos
Public Sub Button3_Click()
con1.Type = "sqlite3"
con1.Host = User.Home
con1.Name = "db1.sqlite"
con1.Open
Print Tex("view_artist", "Artist") ' Esto lo cambias por el nombre de la vista de turno
con1.Close
End
'' sTag es el Book, Author, etc. y sObjeto es el nombre d ela vista, que puede ser vista_book, vista_author etc.
Public Function Tex(sObjeto As String, sTag As String) As String
Dim Res As Result
Dim s As String
Dim f As ResultField
Dim aFields As New String[]
Dim i As Integer
Res = con1.Exec("Select * From " & sObjeto)
aFields.Clear
For Each f In Res.Fields
aFields.Add(f.Name)
Next
i = 0
s = "@" & sTag & " {" & Res[aFields[i]] & ", %clave identificadora\n"
While Res.Avalaible
Inc i
s &= author & " = {" & Res[aFields[i]] & "},\n"
Res.MoveNext
Wend
s &= "}"
Return s
End
CREATE VIEW "view_bibtext" AS SELECT
bibtex.tipoEntrada AS type,
bibtex.id AS id,
bibtex.clave AS clave,
bibtex.hyphenation As hyphenation,
bibtex.author As author,
bibtex.date As date,
bibtex.keywords As keywords,
bibtex.location As location,
bibtex.publisher As publisher,
bibtex.title As title,
bibtex.fecha As creationdate,
bibtex.editor As owner
FROM bibtex
ORDER BY id ASC;
Public Sub BtnExportarBIB_Click()
Dim Res As Result
Dim s As String
Dim f As ResultField
Dim aFields As New String[]
Dim i As Integer
Dim t As Table
Dim w As Integer
Dim tab As String
Res = Conn.Exec("Select * From view_bibtex") ' Exportar todo
'Res = Conn.Exec("Select * From view_bibtex where id=" & txtID.Text) ' Exportar el registro seleccionado
aFields.Clear
For Each f In Res.Fields
aFields.Add(f.Name)
If Len(f.Name) > w Then
w = Len(f.Name)
Endif
Next
While Res.Available
s = "@" & Res[aFields[0]] & " {" & Res[aFields[2]] & ", %clave identificadora\n"
For i = 3 To aFields.Max
tab = ""
If Len(aFields[i])[/i] < w Then
tab = String(w - Len(aFields), " ")
Endif
s &= aFields & tab & " = {" & Res[aFields[i]] & "},\n"
Next
s &= "}"
File.Save("/tmp/" & Res[aFields[1]] & ".bib", s)
Res.MoveNext
Wend
End
(31-08-2023, 14:15)alberto-moyano escribió: Supongo que te referís a poner la conexión en un módulo, lo pensé, veré de instrumentarlo
(31-08-2023, 14:15)alberto-moyano escribió: No lo use nunca, lo voy a estudiar, intuyo que le puedo dar un buen uso
Public Sub Form_Open()
LoadValues()
Me.Title = "Hacking"
End
Private Sub LoadValues()
Dim fld As ResultField
Dim Contenido As Result
Dim aFields As New String[]
Dim fname As String
Contenido = FMain.Conn.Exec("select * from bibtex")
If Contenido.Available Then
Contenido.MoveFirst
For Each fld In Contenido.Fields
aFields.Add(fld.Name)
Next
For Each fname In aFields
fwrite(Me, fname, Contenido[fname])
Next
Endif
End
Private Sub fwrite(ob As Object, sTag As String, sVal As String)
Dim cls As Class
Dim ch As Object
Select Object.Class(ob).Parent.Name
Case "Form", "Container"
For Each ch In ob.Children
fwrite(ch, sTag, sVal)
Next
Case "Control", "UserControl"
If sTag = ob.Tag Then
Select Object.Class(ob).Name
Case "TextBox"
ob.Text = sVal
Case "ComboBox"
If Not ob.ListBox.Exist(sVal) Then
ob.Add(sVal)
Endif
ob.Text = sVal
End Select
Endif
'Case "UserControl"
'Print "UserControl/" & Object.Class(ob).Name
Case Else
Print Object.Class(ob).Parent.Name & "/" & Object.Class(ob).Name
End Select
End