Hi,
I followed one tutorial of making todo app. Well I changed to the desktop app and now i can load a text file from my computer to this listbox.
ListBox has this initialvalues: FirstName LastName Username Password Country
Column count = 5
Now i would like to create button “SaveBtn” which will save all data in one text file on my computer.
The save dialog need to do following:
Save as text file with A) Comma separated between all initialvalues OR … B) doublepoint “:” separated between initialvalues
Save this will ask where to save this file on Windows and Mac too.
Thanks
Thanks sir so much, but it doesnt explain on how to let choice when try to save to computer IF comma or doublepoint between vlues
So sometimes you liek to save all date with : , sometimes with , (comma)
Thanks
Writing to a text file can be done as shown below. Similar code can also be found in the Xojo “Language Reference”.
Dim f as FolderItem
Dim tos as TextOutputStream
Dim strOutFileName As String
Dim strOutString As String
' Assign the required file name to the output file
strOutFileName = "xyz.txt"
' Open output file
f=GetFolderItem(strOutFileName)
If f <> Nil Then
tos = TextOutputStream.Create(f)
' Assign the required value to output string
strOutString = "abc"
tos.WriteLine strOutString
tos.Close
End If
File SaveAs dialogue box can be used as described below.
Dim dlg as New SaveAsDialog
Dim f as FolderItem
Dim strFileSavAsName As String
dlg.SuggestedFileName = "FileName.txt"
' Set initial Directory for SaveAs dialogue box
strFileSavAsName = <FQP of File>
f=GetFolderItem(strFileSavAsName)
dlg.InitialDirectory=f
dlg.Title="Save File As"
' Set up filters for the SaveAs dialogue box, see Xojo "Language Reference"
'dlg.Filter= ???
f=dlg.ShowModal()
If f <> Nil then
strFileSavAsName=dlg.Result.AbsolutePath
' Open the file here and write the data as required.
End if
If there is a need to allow the user to choose the separator character of the output then add “Radio Button” or “Check Box” to let the user choose “,” or “;” as the separator.
To the first exmplae of mr.Lefebvre:
I tried and copy and paste to my “save btn” but it asked me to do some method i’m so newbie so i don’t know.
[code] textOut(extends lb As Listbox)
Dim excelOut As TextOutputStream
Dim dlg as New SaveAsDialog
Dim f as FolderItem
dlg.InitialDirectory=SpecialFolder.Desktop
dlg.promptText=“Save Text As”
dlg.SuggestedFileName=“My Text Out.txt”
dlg.Title=“Text Output”
f=dlg.ShowModal()
If f <> Nil then
excelOut = TextOutputStream.Create(f)
if excelOut <> nil then
excelOut.Write lb.cell(-1,-1)
excelOut.Close
end if
Else
//user canceled
End if
[/code]
Also next code i try to copy and paste and same, so i dont know what to type in settings on method