In all examples I’ve checked, the source-codes explain the saving process of prefs file as this:
[code]
dim f as folderItem
f = SpecialFolder.ApplicationData.child(MyPrefsFile)[/code]
This creates a file directly under “/Library/Application Support”,
But what is the syntax if I want to create a subfolder inside Application Support?
Especially if I want to name the folder as app’s bundle identifier: com.company.app
just do not forget to create the Folder go to the part [quote]f = SpecialFolder.ApplicationData.child (“MyFolderName”)[/quote] because the last part is your preference file.
Aha got it!
so in programming a child can have a child,
now isn’t it interesting?
Another question. please look at this code:
[code] dim f as folderItem
dim t as textoutputStream
f = SpecialFolder.ApplicationData.child(“MyPrefFile”)
if f <> nil then
t = f.createtextFile
if t <> nil then
t.writeLine userName
t.writeLine userGender
if maritalStatus = true then
t.writeLine “true”
else
t.writeLine “false”
end if
t.writeLine offspringNumber
t.close
end if
end if[/code]
What exactly does “if f <> nil then” do here?
isn’t nil = something which doesn’t exist?
and if something is not nil, then it exists.
so why did the coder order a file which already exists to be created again?
Sorry I also forgot to ask:
the “.CreateTextFile” method is not recognized by Xojo autocomplete, but it is functioning well.
Is it a deprecated method?
And if so, what is the modern way to do it?
[quote=116982:@Radium Radiovich]Sorry I also forgot to ask:
the “.CreateTextFile” method is not recognized by Xojo autocomplete, but it is functioning well.
Is it a deprecated method?
And if so, what is the modern way to do it?[/quote]
That I can not answer that but it works fine until the last update, it would be nice if someone who knows can clarify this answer.
[quote=116986:@Dave S]If F were to be NIL then it represents a folder path that CANNOT exist, not one that DOES not exit.
F can be NOT NIL and represent a legal path name, but it may be a path name that does not yet exist… this can be detected with IF NOT F.EXISTS[/quote]
But doesn’t checking the boolean value of F.EXISTS answer both of them? rendering IF <> NIL unnecessary?