Este es mi codigo, el boton 8 es importar y el 9 el de guardar, por si os ayuda.
Uso el gambas 2.20.2 en ubuntu karmic y uso los QT pero con GTK pasa lo mismo.
Aqui el codigo:
PUBLIC SUB Button8_Click()
DIM content AS String[]
DIM index AS Integer
DIM index2 AS String
DIM index3 AS String
DIM index4 AS String
IF ListBox1.Count > 0 THEN
Message.Info("Aun hay " & ListBox1.Count & " preguntas en la lista." & Chr$(13) & "Vaciala primero.")
ELSE
Dialog.Title = "Escoje el archivo"
Dialog.Filter = ["*.faq", "Archivo FAQ", "*", "Todos los archivos"]
IF Dialog.OpenFile() THEN RETURN
content = Split(File.Load(Dialog.Path), Chr$(13), "", TRUE)
FOR index = 0 TO 200
index2 = index
index3 = index & ". "
index4 = index & ". "
FOR EACH index2 IN content
FOR EACH index3 IN content
ListBox1.Add(index3)
NEXT
FOR EACH index4 IN content
ListBox2.Add(index4)
NEXT
NEXT
index += 1
NEXT
MComun.Valor = ListBox1.Count
ValueBox1.Value = MComun.Valor
ProgressBar1.Value = MComun.Valor / 200
TextArea1.SetFocus
TextArea1.Text = ListBox1[1].Text
TextArea2.Text = ListBox2[1].Text
CATCH
Message.Info("No se pudo importar:\n" & Dialog.Path & "\n" & Error.Text)
ENDIF
END
PUBLIC SUB Button9_Click()
DIM content AS String
DIM index AS Integer
IF ListBox1.Count > 0 THEN
FOR index = 0 TO ListBox1.Count - 1
content = content & index & ". "
content = content & ListBox1.List[index]
content = content & Chr$(13)
content = content & index & ". "
content = content & listbox2.List[index]
content = content & Chr$(13)
NEXT
Dialog.Title = "Guardar la FAQ (*.txt)"
Dialog.Filter = ["*.faq", "Archivo FAQ"]
IF Dialog.SaveFile() THEN RETURN
File.Save(Dialog.Path & ".faq", content)
TextArea1.SetFocus
CATCH
Message.Info("No se pudo guardar:\n" & Dialog.Path & "\n" & Error.Text)
ELSE
Message.Info("No hay contenido a guardar")
ENDIF
END
DIM content AS String[]
DIM index AS Integer
DIM index2 AS String
DIM index3 AS String
DIM index4 AS String
IF ListBox1.Count > 0 THEN
Message.Info("Aun hay " & ListBox1.Count & " preguntas en la lista." & Chr$(13) & "Vaciala primero.")
ELSE
Dialog.Title = "Escoje el archivo"
Dialog.Filter = ["*.faq", "Archivo FAQ", "*", "Todos los archivos"]
IF Dialog.OpenFile() THEN RETURN
content = Split(File.Load(Dialog.Path), Chr$(13), "", TRUE)
FOR index = 0 TO 200
index2 = index
index3 = index & ". "
index4 = index & ". "
FOR EACH index2 IN content
FOR EACH index3 IN content
ListBox1.Add(index3)
NEXT
FOR EACH index4 IN content
ListBox2.Add(index4)
NEXT
NEXT
index += 1
NEXT
MComun.Valor = ListBox1.Count
ValueBox1.Value = MComun.Valor
ProgressBar1.Value = MComun.Valor / 200
TextArea1.SetFocus
TextArea1.Text = ListBox1[1].Text
TextArea2.Text = ListBox2[1].Text
CATCH
Message.Info("No se pudo importar:\n" & Dialog.Path & "\n" & Error.Text)
ENDIF
END
PUBLIC SUB Button9_Click()
DIM content AS String
DIM index AS Integer
IF ListBox1.Count > 0 THEN
FOR index = 0 TO ListBox1.Count - 1
content = content & index & ". "
content = content & ListBox1.List[index]
content = content & Chr$(13)
content = content & index & ". "
content = content & listbox2.List[index]
content = content & Chr$(13)
NEXT
Dialog.Title = "Guardar la FAQ (*.txt)"
Dialog.Filter = ["*.faq", "Archivo FAQ"]
IF Dialog.SaveFile() THEN RETURN
File.Save(Dialog.Path & ".faq", content)
TextArea1.SetFocus
CATCH
Message.Info("No se pudo guardar:\n" & Dialog.Path & "\n" & Error.Text)
ELSE
Message.Info("No hay contenido a guardar")
ENDIF
END
Esto es todo el codigo de ambos botones, y supone casi el 25% de la aplicacion. Si sabeis decirme como corregir para que me liste bien los datos, al numero de elementos exactos, yo corregire unos aspectos.