In a project, I create a folder (using the application name) in the ApplicationData folder. Then I store two service data files.
I set that folder’s name in a constant and while I was there, I added two other constants for the two service data files.
I wanted to prefix these two files using the constant I filled to create the folder, appending a specific name and the file extension just like:
kIdiotProof = "Idiot Proof" *
kIPServFile = kIdiotProof + " - Data.txt" *
kIPPrefs = kIdiotProof + " - Prefs.prefs" *
- without the double quotes
This compiles just fine, but the results are *:
"kIdiotProof + - Data.txt"
"kIPPrefs = kIdiotProof + - Prefs.prefs"
Not exactly what I want.
What is wrong ?
a constant is a constant, it can’t be a result of some operation.
But you can create a prebuild script that redefine you computed constant
Thank you Antonio for your kind answer.
Any tip on how I can do that ?
shao_sean
(shao sean)
4
You can use a computed property to do the same thing (or a method)
The script could be like this: (in this example the constants are all in a Module named Module1)
constantValue("Module1.kIPServFile")=constantValue("Module1.kIdiotProof")+ " - Data.txt"
constantValue("Module1.kIPPrefs")=constantValue("Module1.kIdiotProof")+ " - Prefs.prefs"
As Shao wrote, in this case maybe is better a method:
function IPServFile() as string
return kIdiotProof+ " - Data.txt"
end function
and so on
The script suggestion is still valid especially if the constant value is computed base on some “build time” condition.