@@ -664,10 +664,19 @@ static Function saveResults(procedure)
664664 endif
665665End
666666
667+ // Load the specified procedure from storage waves
668+ //
669+ // return errorCode
670+ // 1 Load successfull
671+ // 0 save state loaded with zero elements
672+ // -1 Could not load save state
673+ // -2 CheckSum missmatch. CheckSum has been calculated and was stored in
674+ // global variable
667675static Function saveLoad ( procedure)
668676 STRUCT procedure & procedure
669677
670678 Variable numResults
679+ string CheckSum
671680
672681 Wave /T declWave = getDeclWave ()
673682 Wave /I lineWave = getLineWave ()
@@ -676,72 +685,72 @@ static Function saveLoad(procedure)
676685 Wave /T SaveStringsWave = getSaveStrings ()
677686 Wave SaveVariablesWave = getSaveVariables ()
678687
688+ // if maximum storage capacity was reached (procedure.row == -1) or
689+ // Element not found (procedure.row == endofWave) --> nothing loadable
679690 if (( procedure. row < 0 ) || ( procedure. row == Dimsize ( SaveStringsWave, 0 )) || ( Dimsize ( SaveStringsWave, 0 ) == 0 ))
680- // if maximum storage capacity was reached (procedure.row == -1) or Element not found (procedure.row == endofWave) there is nothing to load.
681691 debugPrint ( "save state not found" )
682692 return -1
683- elseif ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
684- // procedure marked as non valid by AfterRecompileHook
685- // checksum needs to be compared.
693+ endif
694+ if ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
695+ // procedure marked as not valid by
696+ // AfterCompiledHook --> updatePanel --> saveReParse
697+ // --> CheckSum needs to be compared.
686698
687- // getting checksum
688- if ( setChecksum ( procedure) != 1 )
689- debugPrint ( "error creating variable" )
699+ if ( ! setChecksum ( procedure))
700+ debugPrint ( "error creating CheckSum" )
690701 return -1
691702 endif
692- // comparing checksum
693- if ( cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , getChecksum ()) != 0 )
694- // checksum changed. return -2 to indicate that calculation was already done by setChecksum.
695- debugPrint ( "Checksum missmatch: Procedure has to be reloaded." )
703+ CheckSum = getCheckSum ()
704+ if ( !! cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , CheckSum))
705+ debugPrint ( "CheckSum missmatch: Procedure has to be reloaded." )
696706 return -2
697- else
698- //mark as valid
699- debugPrint ( "Checksum match: Procedure marked valid." )
700- SaveVariablesWave[ procedure. row][ 0 ] = 1
701707 endif
708+ debugPrint ( "CheckSum match: " + CheckSum)
709+
710+ SaveVariablesWave[ procedure. row][ 0 ] = 1
711+ debugPrint ( "Procedure " + procedure. fullname + " marked as valid." )
702712 endif
703713
704- // load results from free waves
705714 numResults = Dimsize ( SaveWavesWave[ procedure. row][ 0 ] , 0 )
706715 Redimension / N= ( numResults, -1 ) declWave, lineWave
707- if ( numResults > 0 )
708- WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
709- WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
710- declWave[][ 0 ] = load0 [ p][ 0 ]
711- declWave[][ 1 ] = load0 [ p][ 1 ]
712- lineWave[] = load1 [ p]
713- debugPrint ( "save state loaded successfully" )
714- return 1
715- else
716+ if ( numResults == 0 )
716717 debugPrint ( "no elements in save state" )
717718 return 0
718719 endif
720+
721+ WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
722+ WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
723+ declWave[][ 0 ] = load0 [ p][ 0 ]
724+ declWave[][ 1 ] = load0 [ p][ 1 ]
725+ lineWave[] = load1 [ p]
726+
727+ debugPrint ( "save state loaded successfully" )
728+ return 1
719729End
720730
721731// Identifier = module#procedure
722732static Function getSaveRow ( Identifier)
723733 String Identifier
724734
725735 Wave /T SaveStrings = getSaveStrings ()
726- Variable found, endOfWave
736+ Variable found, endOfWave, element
727737
728738 FindValue / TEXT= Identifier/ TXOP=4/ Z SaveStrings
729- if ( V_value == -1 )
730- // element not found
739+ if ( V_Value == -1 )
740+ debugPrint ( "Element not found" )
731741 return Dimsize ( SaveStrings, 0 )
732- else
733- // element found at position V_value
734-
735- // check for inconsistency.
736- if ( V_value > CsaveMaximum )
737- DebugPrint ( "Storage capacity exceeded" )
738- // should only happen if(CsaveMaximum) was touched on runtime.
739- // Redimension/Deletion of Wave could be possible.
740- return ( CsaveMaximum - 1 )
741- endif
742-
743- return V_value
744742 endif
743+ element = V_Value
744+
745+ // check for inconsistency.
746+ if ( element > CsaveMaximum )
747+ debugPrint ( "Storage capacity exceeded" )
748+ // should only happen if(CsaveMaximum) was touched on runtime.
749+ // Redimension/Deletion of Wave could be possible.
750+ return ( CsaveMaximum - 1 )
751+ endif
752+
753+ return element
745754End
746755
747756// drop first item at position 0. push all elements upward by 1 element. Free last Position.
@@ -1060,6 +1069,8 @@ End
10601069
10611070static Function setParsingTime ( numTime)
10621071 Variable numTime
1072+
1073+ debugPrint ( "parsing time:" + num2str ( numTime))
10631074 return setGlobalVar ( "parsingTime" , numTime)
10641075End
10651076
0 commit comments