How? I have great difficulty believing that one can take a sketch from system A to a fresh IDE install of the IDE on system B and the IDE on system B will know that the sketch was written for a specific board.
Sometimes you able to understand this from the code... using a specific libraries... format of registers etc..
If the code doesn't has such "markers", it probably could run on any board
That is not exactly what I said, although I agree that it could be read that way. The board and COM port information is associated with the sketch on my main PC, which is what I had in mind
If I save a sketch with say a Nano on COM9 selected, when I open the sketch again the same board and COM port are automatically associated with it. If I then change the board and/or COM port and save it again, close the sketch and open it again then the newly associated board and COM port are once again associated with the sketch
Clearly there is some "magic" going on behind the scenes but how and where the board and port metadata is held I don't know
I am sorry if my previous reply caused any confusion
That works as well in IDE 1.x But from memory, IDE 2.x is more clever. If I have a sketch for a Nano and its port, close and open the IDE and after that open a sketch for a Mega with its port, they are reflected; note that I stated that this is from memory.
I did know but as I don't have IDE 2.x at the moment I'm not sure.
"If I save a sketch with say a Nano on COM9 selected, when I open the sketch again the same board and COM port are automatically associated with it. If I then change the board and/or COM port and save it again, close the sketch and open it again then the newly associated board and COM port are once again associated with the sketch".
Which means there is zero relationship between the Sketch, the board, and the COM port.
Changing the board and COM port will then be persistent to all old and new sketches opened. This doesn't make any practical sense to me ....
It's a bit like taking your car to a garage for a service, and they use the service manual for the last car they had in ...
@daba this is not a very productive way to participate in a technical discussion with people who are trying to provide free assistance. Please try to act in a more polite and professional manner. You are welcome to dispute the claims of others, but if you want to do that then specify exactly what it is you think is incorrect and provide evidence to back up what you say.
Which version of Arduino IDE are you using (e.g., "2.3.2")? The version is shown on the window title bar and also in the dialog that opens when you select Help > About (or Arduino IDE > About Arduino IDE for macOS users) from the Arduino IDE menus. The feature @UKHeliBob is referring to is specific to Arduino IDE 2.x.
I understand your comments, and apologise for being terse, however, I find the feedback I have received to be inconsistent with my experiences.
I am using IDE 1.8.19,k and what I have found is that once I "set" a board on any project I have open, (and the COM port is irrelevant, as that may change depending on the physical connection), that setting persists, no matter what sketch I open.
Simply put, your "board" choice is set in the IDE, and no matter what sketch you open, or re-open, that board remains as the current board, even if it is not the board the sketch was written for...
Of course, the work-around is to document in the sketch the target board for the sketch, but you will still manually have to read that info, and change the "board" setting to suit the open project.
I feel this could be more automated, the INO file specifying the board, and the IDE changing it according to the INO
That depends on your exact requirement. All I can say is that using IDE 2.3.2 saving a sketch with a board and COM port defined means that when the sketch is opened again on the same PC the board and COM port is set to that active at the time of saving
This is using Windows 10
I have no experience of using the IDE to any extent on any other OS