
Determine the version of a procedure file


aclight
//** // Determine the version of a compiled procedure window // named procedureWinTitleStr. // The version is defined using the #pragma version // compiler directive. For example, // #pragma version=1.05. // // As stated in the Igor documentation, the line must // start flush with the left of the window (that is, there // can be no leading whitespace). Spaces // and tabs within the directive are ignored. // // Returns NaN if procedure window doesn't exist, // 1.00 if no version is defined in the procedure window, // or the version that is defined in the procedure window. //* Function GetProcedureVersion(procedureWinTitleStr) String procedureWinTitleStr // By default, all procedures are version 1.00 unless // otherwise specified. Variable version = 1.00 Variable versionIfError = NaN String procText = ProcedureText("", 0, procedureWinTitleStr) if (strlen(procText) <= 0) return versionIfError // Procedure window doesn't exist. endif String regExp = "(?i)(?:^#pragma|\\r#pragma)(?:[ \\t]+)version(?:[\ \t]*)=(?:[\ \t]*)([\\d.]*)" String versionFoundStr SplitString/E=regExp procText, versionFoundStr if (V_flag == 1) version = str2num(versionFoundStr) endif return version End

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
April 13, 2010 at 10:15 am - Permalink
April 13, 2010 at 02:45 pm - Permalink
Having a return of 0.00 (since NaN is used as a No Procedure File Error flag) still seems a better "no pragma defined" return value than 1.00. While Igor allows procedure files of version = 0.00, I suspect the number of users who purposely code a procedure file with such a version number is far, far smaller than the number who actually use no version pragma in their procedure file.
This is BTW a good standard piece of code to have around to help oversee code development.
Thanks!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
April 13, 2010 at 05:13 pm - Permalink
Motivated by Jan's recent post (https://www.wavemetrics.com/forum/igor-pro-wish-list/warn-if-multiple-s…), I'm wondering if the method shown here is still the best way to get a procedure file version from the version pragma?
December 7, 2021 at 07:16 am - Permalink
aclight's snippet gives the version of a currently loaded procedure.
This gives the version from a file:
December 7, 2021 at 08:31 am - Permalink