A Few Questions

Hi,

I ran into a few problems while working on my code.

1. Is there a way to easily find the coordinates of a window?
2. How do you make an experiment perform some preset actions upon closure, such as resetting certain waves within the root folders or deleting the command history?
3. Can a user make it so someone using an experiment cannot see/alter the code in the experiment procedure window?
4. I currently have the following code to disable saving on my program because I would like users to save using other methods. Is this how you would go about doing so?
SetIgorMenuMode "File", "Save Experiment", DisableItem
SetIgorMenuMode "File", "Save Experiment As", DisableItem
SetIgorMenuMode "File", "Save Experiment Copy", DisableItem

Is there a way to stop Igor from prompting you to save changes when closing an experiment? And what is the difference between save experiment as and save experiment copy?

Any help would be much appreciated. Thank you.
Ken wrote:
1. Is there a way to easily find the coordinates of a window?

The GetWindow operation.
Quote:
2. How do you make an experiment perform some preset actions upon closure, such as resetting certain waves within the root folders or deleting the command history?

The IgorQuitHook function:
DisplayHelpTopic "IgorQuitHook"

Quote:
3. Can a user make it so someone using an experiment cannot see/alter the code in the experiment procedure window?

Yes.
DisplayHelpTopic "Invisible Procedure Files"

Quote:
4. I currently have the following code to disable saving on my program because I would like users to save using other methods. Is this how you would go about doing so?
SetIgorMenuMode "File", "Save Experiment", DisableItem
SetIgorMenuMode "File", "Save Experiment As", DisableItem
SetIgorMenuMode "File", "Save Experiment Copy", DisableItem

Is there a way to stop Igor from prompting you to save changes when closing an experiment?

Your method should work fine. You might also look at the ExperimentModified operation.
Quote:
And what is the difference between save experiment as and save experiment copy?

With Save As, the saved experiment becomes the current experiment, and further changes to the experiment will be saved into that experiment.

With Save Copy, the saved experiment is a "snapshot" of the current experiment, but further changes don't affect that copy, only the open experiment.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Regarding #2, even though I added ExperimentModified 0 into one of the functions of an attached procedural file and ran the function before trying to close the experiment, the command didn't seem to do anything. I managed to substitute ExperimentModified with IgorBeforeQuitHook instead using the following code. I didn't end up using IgorQuitHook though; I'm not sure how I would use it and where that would come in.

function IgorBeforeQuitHook(unsavedExp,unsavedNotebooks,unsavedProcedures)
    variable unsavedExp, unsavedNotebooks, unsavedProcedures
    unsavedExp = 1 // Skipping prompting save
    return unsavedExp
end


For making the procedural file invisible in #3, I split up my code into two files: one an ipf that went into user procedures that consisted of the main code, and the other a short procedure file that simply calls that ipf. Since files called with #include are automatically write-protected, #pragma hide=1 applied to it. The reason I did it this way was because I had difficulties making the original procedural file write-protected or read-only. Whenever I clicked on the pencil icon to write-protect the procedure and reopened the experiment, the write-protection would disappear.

Everything else worked.
Quote:
The reason I did it this way was because I had difficulties making the original procedural file write-protected or read-only. Whenever I clicked on the pencil icon to write-protect the procedure and reopened the experiment, the write-protection would disappear.


Write-protect is an Igor setting and is not stored with the file. Read-only is an OS setting.

Make it read-only in the Windows desktop. Right-click the file, choose properties, and click the Read-Only checkbox.