Code does not compile with IGOR 8: issue with /G variable


I have been using a code that was compiling with Igor 6, but does not with Igor 8.04.

The  beginning of the code is inserted below. The error code is:

Unknown/inappropriate name or symbol


LLimiteWN is a Global variable that is no longer recognized by the compiler.

Thanks in advance for your help.






#Pragma rtGlobals=0
#include "Keyword-Value-deliminor"
#include <Strings as Lists>
#include "GraphFormat.h"
#include "Cross_Hair_Cursors_for_Read_NicIR"

Menu "Macros"                       // .NicIR_mini2
    submenu "SaveNicoletFile"
    submenu "BaseLine"
        "New Baseline"
        "Validate Cursor/Q"
        "Reset Baseline"
        "Correct Baseline"
        "Table BL points"
    submenu "Change Values"
        "Delete Point"
    "Search Peaks"

Function/S LesWaveListes()

Function Init_glabalVar4Read()

    VARIABLE/G  LLimiteWN=400, HLimiteWN=4000, SSP=2, DisplayOrAppend, Is_Signed, ToSkip
    VARIABLE/G  NoLimite=0, LLimite, HautLimite
    VARIABLE/G  HeaderSize, FileSize, PointsInFile, Gain, ScanPoints, NumOfPoints, Peak_Location, NumOfScan
    VARIABLE/G  Ddate,Dtime,Year,moon,day,hour,minute,seconde,tick,temp1
    VARIABLE/G/D    GlobalOffset, GlobalFactor, FirstX, theDeltaX, LastX, XScale
    VARIABLE/G/D    XPosition, YPosition, LaserFrequency,ScanPeak_Location,MaxValY,MinValY
    VARIABLE/G  Velocity, Aperture,FFTPoints, NumScanBckgrd,NumPntsFFT
    STRING/G        Sdate,Stime, FileTitle,Le_Type,Le_Flags,Le_text,gFExtension= ".I*",Auto,OtherExt,History
    VARIABLE/D/G    xOfCursorA,xOfCursorB
    VARIABLE/G  DifFirstX
    STRING/G           CurrentWave,Head1,Head2,Head3,dw,nomFich,fSource,ListeW
    STRING/G        text
    VARIABLE/G  continuer

Function Init_glabalVar4Subs()

    VARIABLE/G  lx, rx
    VARIABLE/G  gvalueF,gIncrement
    VARIABLE/G  dw_max,dw_min,aw_max,aw_min,bw_max,bw_min
    VARIABLE/G  lx_dw,rx_dw,lx_aw,rx_aw,lx_bw,rx_bw
    VARIABLE/G  Axies_decalage1,Axies_decalage2,Axies_decalage3
    STRING/G        gaw, gbw, gdw

Proc KillGlobals4Subs()

    KillStrings gaw,gbw,gdw
    KillVariables dw_max,dw_min,aw_max,aw_min,bw_max,bw_min
    KillVariables lx_dw,rx_dw,lx_aw,rx_aw,lx_bw,rx_bw
    KillVariables Axies_decalage1,Axies_decalage2,Axies_decalage3
    KillVariables lx,rx

Function Init_glabalVar4doProc()

    VARIABLE/G  KeepOld,undothis,defaultvalueV1,defaultvalueV2,var3
    STRING/G        promptaW, awList, bwList, dwList, promptV1, promptP1,PromptV2,v2List
    STRING/G        default_aW, default_bW, default_dW,defaultvalueP2,defaultvalueP2,para1List,defaultvalueP1
    STRING/G        wNameExt
// CoordonnÈes des curseurs et nombre de curseurs
    VARIABLE/G  nbCsr
    STRING/G        interWx,interWy

// Chargement d'un fichier au format SPX
Macro LoadNicoletFile(LowLimiteWN,HihgLimiteWN,AutoMan,WholeFolder,SampleSpace,FExtension,ForDisplay,OtherExtension)
    VARIABLE LowLimiteWN = LLimiteWN*(1-nolimite),HihgLimiteWN =HLimiteWN*(1-nolimite),WholeFolder=2
    VARIABLE ForDisplay=2
    STRING  SampleSpace= num2str(SSP),FExtension = gFExtension,AutoMan,OtherExtension=""
    Prompt ForDisplay, "Display or Append", popup, "Display;Append;Display folder;None";
    Prompt AutoMan, "Standard or manual range ?",popup,"Manual range;Automatic range"
    Prompt SampleSpace, "Standard range", popup, "VFIR : 0 - 1975 cm-1 (SSP=8);FIR : 0 - 3950 cm-1 (SSP=4);MIR : 0 - 7899 cm-1 (SSP=2);Vis-NIR : 0 - 15798 cm-1 (SSP=1);UV-Vis : 0 - 31596 cm-1 (SSP=0.5)";
    Prompt LowLimiteWN,"First wavenumber in cm-1  ( 0  => lower limit)"
    Prompt HihgLimiteWN,"Last wavenumber  in cm-1 ( 0  => upper limit)"
    Prompt WholeFolder, "Read All Files in the Folder ?",popup,"Whole Folder with extension:;One File"
    Prompt FExtension, "File Extension :",popup, "all;A;B;C;I;S;R"
    Prompt OtherExtension, "Other Extension ?"



Can you create a small self contained example? I don't see an if statement in the code you posted.

The help file "What's New in Igor Pro 7" contains this:

Support for rtGlobals=0 is gone - acts like rtGlobals=1.

You need to add this statement:

NVAR LLimiteWN = root:LLimiteWN

in any function that uses the global numeric variable LLimiteWN (assuming that the globals are in the root data folder) and likewise for all other global numeric variables.

Similarly you need to add this statement:

SVAR CurrentWave = root:CurrentWave

in any function that uses the global string variable CurrentWave and likewise for all other global string variables.

For background information, execute this:

DisplayHelpTopic "Accessing Global Variables And Waves"

For future programming, it is best to avoid global variables as much as practical. There is a good and simple explanation of this at this web page which I will quote here:

The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables. 

To understand how the application works, you pretty much have to take into account every function which modifies the global state. That can be done, but as the application grows it will get harder to the point of being virtually impossible (or at least a complete waste of time). 

If you don't rely on global variables, you can pass state around between different functions as needed. That way you stand a much better chance of understanding what each function does, as you don't need to take the global state into account.


DisplayHelpTopic "Uses For Global Variables"

And for more search for "Why are global variables bad?"