Changeset 11


Ignore:
Timestamp:
Mar 15, 2013 5:03:32 PM (9 years ago)
Author:
ilavsky
Message:

Added cleanup for weird characters in data wave and folder, such as (,),%,$,& etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • User Procedures/Irena/IR1_ImportData.ipf

    r6 r11  
    11#pragma rtGlobals=1             // Use modern global access method.
    2 #pragma version=2.15
     2#pragma version=2.16
    33Constant IR1IversionNumber = 2.15
    44Constant IR1TrimNameLength = 28
     
    99//*************************************************************************/
    1010
     11//2.16 added cleanup of weird characters (,),%, {, } of names. Allowed by igor but cause problems to my opther code.
    1112//2.15 added vertical scrolling for panel.
    1213//2.14 added option to trunkate long names in front or end.
     
    493494        //and print in history, so user has some feedback...
    494495        print "Imported data from :"+DataPathName+selectedFile+"\r"
    495         print "\tData stored in :\t\t\t"+NewFldrNm
     496        print "\tData stored in :\t\t\t"+IR1I_RemoveBadCharacters(NewFldrNm)
    496497        if(DataContainErrors || CreateSQRTErrors || CreatePercentErrors)
    497                 print  "\tNew Wave names are :\t"+ NewIntName+"\t"+NewQName+"\t"+NewEName+"\r"
     498                print  "\tNew Wave names are :\t"+ IR1I_RemoveBadCharacters(NewIntName)+"\t"+IR1I_RemoveBadCharacters(NewQName)+"\t"+IR1I_RemoveBadCharacters(NewEName)+"\r"
    498499        else //no errors...
    499500                print  "\tNew Wave names are :\t"+ NewIntName+"\t"+NewQName+"\r"
     
    722723       
    723724        if(stringMatch(NewIntensityWaveName,"*<fileName>*")==0)
     725                NewIntName = IR1I_RemoveBadCharacters(NewIntName)
    724726                NewIntName = CleanupName(NewIntensityWaveName, 1 )
    725727                NewIntName=IR1I_TrunkateName(NewIntName,TrunkateStart,TrunkateEnd)
     
    732734                        NewIntName = TempFirstPart+IR1I_TrunkateName(StringFromList(0,selectedFile,"."),TrunkateStart,TrunkateEnd)+tempLastPart
    733735                endif
     736                NewIntName = IR1I_RemoveBadCharacters(NewIntName)
    734737                NewIntName = CleanupName(NewIntName, 1 )
    735738        endif
    736739        if(stringMatch(NewQwaveName,"*<fileName>*")==0)
     740                NewQName =IR1I_RemoveBadCharacters(NewQName)
    737741                NewQName = CleanupName(NewQwaveName, 1 )
    738742                NewQName=IR1I_TrunkateName(NewQName,TrunkateStart,TrunkateEnd)
     
    745749                        NewQName = TempFirstPart+IR1I_TrunkateName(StringFromList(0,selectedFile,"."),TrunkateStart,TrunkateEnd)+tempLastPart
    746750                endif
     751                NewQName =IR1I_RemoveBadCharacters(NewQName)
    747752                NewQName = CleanupName(NewQName, 1 )
    748753        endif
    749754        if(stringMatch(NewErrorWaveName,"*<fileName>*")==0)
     755                NewEName =IR1I_RemoveBadCharacters(NewEName)
    750756                NewEName = CleanupName(NewErrorWaveName, 1 )
    751757                NewEName=IR1I_TrunkateName(NewEName,TrunkateStart,TrunkateEnd)
     
    758764                        NewEName = TempFirstPart+IR1I_TrunkateName(StringFromList(0,selectedFile,"."),TrunkateStart,TrunkateEnd)+tempLastPart
    759765                endif
     766                NewEName =IR1I_RemoveBadCharacters(NewEName)
    760767                NewEName = CleanupName(NewEName, 1 )
    761768        endif
    762769        if(stringMatch(NewQErrorWaveName,"*<fileName>*")==0)
     770                NewQEName =IR1I_RemoveBadCharacters(NewQEName)
    763771                NewQEName = CleanupName(NewQErrorWaveName, 1 )
    764772                NewQEName=IR1I_TrunkateName(NewQEName,TrunkateStart,TrunkateEnd)
     
    771779                        NewQEName = TempFirstPart+IR1I_TrunkateName(StringFromList(0,selectedFile,"."),TrunkateStart,TrunkateEnd)+tempLastPart
    772780                endif
     781                NewQEName =IR1I_RemoveBadCharacters(NewQEName)
    773782                NewQEName = CleanupName(NewQEName, 1 )
    774783        endif
     
    808817
    809818        IR1I_KillAutoWaves()
     819end
     820//************************************************************************************************************
     821//************************************************************************************************************
     822//************************************************************************************************************
     823//************************************************************************************************************
     824Function/S IR1I_RemoveBadCharacters(StringName)
     825        string StringName
     826       
     827        //here we can clean up waht Igor allows but would be major problem with my code, such as ( or ) from names
     828        make/Free/T/N=0 ListOfBadChars
     829        ListOfBadChars = {"(", ")", "{","}","%","&","$","#","@"}
     830        variable i
     831        For (i=0;i<numpnts(ListOfBadChars);i+=1)
     832                StringName = ReplaceString(ListOfBadChars[i], StringName, "_" )
     833        endfor
     834        return StringName
    810835end
    811836//************************************************************************************************************
     
    908933                        endif
    909934                        selectedFile=IR1I_TrunkateName(selectedFile,TrunkateStart,TrunkateEnd)
     935                        selectedFile =IR1I_RemoveBadCharacters(selectedFile)
    910936                        selectedFile = CleanupName(selectedFile, 1 )
    911937                        NewDataFolder/O/S $selectedFile
Note: See TracChangeset for help on using the changeset viewer.