Wrong file being addressed - old different one which has been replaced but keeps reappearing

#If TargetWindows Then
// Windows-specific code here
h = GetFolderItem(“c:\axojo\stock.ini”)
#ElseIf TargetMacOS
// Mac-specific code goes here
h = GetFolderItem(“stock.csv”) stock.csv gets replaced by an earlier file name ots.csv
#ElseIf TargetLinux Then
// Linux-specific code goes here
#ElseIf TargetXojoCloud Then
// Xojo Cloud-specific code goes here
#EndIf

Works OK on windows

That isn’t a full path.

GetFolderItem(“c:\axojo\stock.ini”)

That is…
So you will get files from different places on the Mac, depending upon whether you are running in debug or compiled mode.

If you keep your files in
SpecialFolder.applicationdata.child(“myapp”) folder
then you will always be able to find them

Your code would then not even need to be OS specific

h = SpecialFolder.applicationdata.child(“axojo”).child(“stock.csv”)

would work for everything

but try


#If TargetWindows Then
// Windows-specific code here
h = SpecialFolder.applicationdata.child("axojo").child(“stock.ini”)   //may as well be CSV!
#ElseIf TargetMacOS
// Mac-specific code goes here
h = SpecialFolder.applicationdata.child("axojo").child(“stock.csv”) 
#ElseIf TargetLinux Then
// Linux-specific code goes here
#ElseIf TargetXojoCloud Then
// Xojo Cloud-specific code goes here
#EndIf

Sounds good, but didn’t work. On the Mac or Windows

With respect, it does.
Assuming you have SpecialFolder.applicationdata.child(“axojo”) created already to hold the files.
What does your code look like now?

What do you mean “doesn’t work” ? Please provide details.

h=specialfolder… h is assigned 0 not a folder
The run then crashes and the debug facility does not allow me to make any further investigations. On VB6 I would have still had control and could restart at a previos point or later.
Folder AXOJO contains just myapp, stock.csv, stock.ini, and a picture

Exactly as you suggested.

Then the path has not been set up correctly.
And h is supposed to be a folder item, not a folder

what do you get from

if specialFolder.applicationdata.child(“axojo”) = nil then msgbox "folderitem is nil"

if specialFolder.applicationdata.child(“axojo”).exists = false then msgbox "axojo isnt there"

Folder AXOJO contains just myapp, stock.csv, stock.ini, and a picture

Where EXACTLY is folder AXOJO on your mac?

Did you create the folder and place your file in it first?

h is defined as : dim h as folderitem
Everything has previously worked as per manual and example progs.
My suggestion is that the Xojo system gets into a twist if I sometimes code on Windows and then after transfering to my Mac via a memory stick I then do a bit more on the Mac and then back to Windows. (this happens when my wife is on a Zoom session and I get banished to another room with the MacBook Air M1). Still doesn’t explain why system remembers the name of a previous data file and overwrites the coded one.

However I have recovered an earlier version which does work on Windows and when transferred to Mac works (ie runs) there as well. If my theory is correct (that it is alternating development between systems causing the problem) I am going to just do the coding on Windows and just test that it runs on the Mac.
So far so good.

Yes, folder created in Explorer on Windows. Placed on C: drive on Windows, on the desktop on the Mac.

In that case you could be doing:

Var  f as FolderItem, path as String

#if   (TargetWindows=True)  then path = "C:\axojo\stock.ini”
#if  (TargetMacOS=True)  then path = "/Users/user/Desktop/stock.csv"

f = new FolderItem (path, FolderItem.PathModes.Native)

where you replace ‘user’ in your macOS path with your username.

BTW, are you dealing with stock.ini or stock.csv?

So far all suggestions have sounded good but not worked. However have been able to make progress by using an earlier version of my program. This of course has lead to more Xojo eccentricities: the latest being that the automatic sort facility is nearly what I want but insists on including the header row in the sort! Not at all rational - who would want that? Any suggestions please how to exclude the header row from the auto sort.

The automatic sort of what?

Of a listbox - sorry.

OK - you’ve got HasHeader set to ON in the IDE for that listbox?

Yes, HasHeader set in the IDE.
I should perhaps give you a bit of history. I used MS XL to provide my client with a stock control program all of 30 years ago and it has been working very well ever since. She runs an antique jewelry with currently 2800 items on the go. She started out running it on Windows, but some time ago switched to an iMac running a compatible version of MS Office. While this still works it is showing its age and so she has invested in a new iMac. To our annoyance MS insists on upgrading Office which is now incompatible and wont run the XL prog. So… I exported the stock sheet to a csv file to use on a new Xojo Prog. Have been making good progress but I keep hitting Xojo problems like this header problem (not at all helped by obscure error messages from the debugger). I don’t think I should upload the prog but of course if push comes to shove…
The SpecialFolder way did not work at all, but the original methods do (having gone back to an earlier stage in the development. Having used a lot of programming languages an systems (principally VB6 since I retired in 1988) I have to say I am not too impressed with Xojo - there are too many obvious system problems which should not arise.
Thank you, everyone for trying to help but can’t report any success yet.

You can upload/share a simpler (“just-the-problem-I-have”) kind of program for:

  • specialfolder
  • listbox header

where people can see/reproduce what you did and give you better answers.

We can tell you are getting frustrated, but the only reason the specialfolder way might not work is if you misinterpreted it and did it incorrectly.

It’s utterly standard, normal, and in all the time I have used Xojo, bulletproof.
Unlike the use of hard coded paths and incomplete paths, which will work now and then but not in all situations.

There is no need to have an ini file on Windows and a CSV file on Mac, either.
Code for one, why not?

obscure error messages from the debugger

Are only obscure if you are unfamiliar.
You haven’t mentioned errors before in this post history, so it sounds like there is a fair amount of trial and error happening in the code.

I exported the stock sheet to a csv file to use on a new Xojo Prog

Probably would have been better as a SQLite database, to be honest, given the stock control aspect.
But walk , then run.

So when you talk about the header line being sorted, do you mean the header line in the Listbox or the header line in the CSV file?

I was going to say that my listbox sorts fine but then I remembered that I manage that by dumping the listbox’s contents and reloading it from the corresponding SQLite database, adjusting the ORDER BY clause depending which header cell the user clicked.

And I agree with @Jeff_Tullin that data is best stored in an SQLite database than a CSV file on disk. You can import the data into an SQLite database using the SQLite CLI tool, if you need to.

Edit: Oh, and the other nice thing about SQLite databases is that you can just move it from macOS to Linux to Windows and it doesn’t mind at all.