@@ -649,12 +649,14 @@ End
649649// Parses all procedure windows and write into the decl and line waves
650650Function /S parseProcedure ( procedure, [ checksumIsCalculated] )
651651 STRUCT procedure & procedure
652- Variable checksumIsCalculated
652+ Variable checkSumIsCalculated
653653
654654 if ( ParamIsDefault ( checksumIsCalculated))
655- checksumIsCalculated = 0
655+ checkSumIsCalculated = 0
656+ endif
657+ if ( ! checkSumIsCalculated)
658+ DebugPrint ( "CheckSum needs to be calculated" )
656659 endif
657- DebugPrint ( "Checksum recalc:" + num2str ( checksumIsCalculated))
658660
659661 // start timer
660662 Variable timer = timerStart ()
@@ -720,10 +722,19 @@ static Function saveResults(procedure)
720722 endif
721723End
722724
725+ // Load the specified procedure from storage waves
726+ //
727+ // return errorCode
728+ // 1 Load successfull
729+ // 0 save state loaded with zero elements
730+ // -1 Could not load save state
731+ // -2 CheckSum missmatch. CheckSum has been calculated and was stored in
732+ // global variable
723733static Function saveLoad ( procedure)
724734 STRUCT procedure & procedure
725735
726736 Variable numResults
737+ string CheckSum
727738
728739 Wave /T declWave = getDeclWave ()
729740 Wave /I lineWave = getLineWave ()
@@ -732,72 +743,72 @@ static Function saveLoad(procedure)
732743 Wave /T SaveStringsWave = getSaveStrings ()
733744 Wave SaveVariablesWave = getSaveVariables ()
734745
746+ // if maximum storage capacity was reached (procedure.row == -1) or
747+ // Element not found (procedure.row == endofWave) --> nothing loadable
735748 if (( procedure. row < 0 ) || ( procedure. row == Dimsize ( SaveStringsWave, 0 )) || ( Dimsize ( SaveStringsWave, 0 ) == 0 ))
736- // if maximum storage capacity was reached (procedure.row == -1) or Element not found (procedure.row == endofWave) there is nothing to load.
737749 debugPrint ( "save state not found" )
738750 return -1
739- elseif ( SaveVariablesWave[ procedure. row][ 0 ] == 0 )
740- // procedure marked as non valid by AfterRecompileHook
741- // checksum needs to be compared.
751+ endif
752+ if ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
753+ // procedure marked as not valid by
754+ // AfterCompiledHook --> updatePanel --> saveReParse
755+ // --> CheckSum needs to be compared.
742756
743- // getting checksum
744- if ( setChecksum ( procedure) != 1 )
745- debugPrint ( "error creating variable" )
757+ if ( ! setChecksum ( procedure))
758+ debugPrint ( "error creating CheckSum" )
746759 return -1
747760 endif
748- // comparing checksum
749- if ( cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , getChecksum ()) != 0 )
750- // checksum changed. return -2 to indicate that calculation was already done by setChecksum.
751- debugPrint ( "Checksum missmatch: Procedure has to be reloaded." )
761+ CheckSum = getCheckSum ()
762+ if ( !! cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , CheckSum))
763+ debugPrint ( "CheckSum missmatch: Procedure has to be reloaded." )
752764 return -2
753- else
754- //mark as valid
755- debugPrint ( "Checksum match: Procedure marked valid." )
756- SaveVariablesWave[ procedure. row][ 0 ] = 1
757765 endif
766+ debugPrint ( "CheckSum match: " + CheckSum)
767+
768+ SaveVariablesWave[ procedure. row][ 0 ] = 1
769+ debugPrint ( "Procedure " + procedure. fullname + " marked as valid." )
758770 endif
759771
760- // load results from free waves
761772 numResults = Dimsize ( SaveWavesWave[ procedure. row][ 0 ] , 0 )
762773 Redimension / N= ( numResults, -1 ) declWave, lineWave
763- if ( numResults > 0 )
764- WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
765- WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
766- declWave[][ 0 ] = load0 [ p][ 0 ]
767- declWave[][ 1 ] = load0 [ p][ 1 ]
768- lineWave[] = load1 [ p]
769- debugPrint ( "save state loaded successfully" )
770- return 1
771- else
774+ if ( numResults == 0 )
772775 debugPrint ( "no elements in save state" )
773776 return 0
774777 endif
778+
779+ WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
780+ WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
781+ declWave[][ 0 ] = load0 [ p][ 0 ]
782+ declWave[][ 1 ] = load0 [ p][ 1 ]
783+ lineWave[] = load1 [ p]
784+
785+ debugPrint ( "save state loaded successfully" )
786+ return 1
775787End
776788
777789// Identifier = module#procedure
778790static Function getSaveRow ( Identifier)
779791 String Identifier
780792
781793 Wave /T SaveStrings = getSaveStrings ()
782- Variable found, endOfWave
794+ Variable found, endOfWave, element
783795
784796 FindValue / TEXT= Identifier/ TXOP=4/ Z SaveStrings
785- if ( V_value == -1 )
786- // element not found
797+ if ( V_Value == -1 )
798+ debugPrint ( "Element not found" )
787799 return Dimsize ( SaveStrings, 0 )
788- else
789- // element found at position V_value
790-
791- // check for inconsistency.
792- if ( V_value > CsaveMaximum )
793- DebugPrint ( "Storage capacity exceeded" )
794- // should only happen if(CsaveMaximum) was touched on runtime.
795- // Redimension/Deletion of Wave could be possible.
796- return ( CsaveMaximum - 1 )
797- endif
798-
799- return V_value
800800 endif
801+ element = V_Value
802+
803+ // check for inconsistency.
804+ if ( element > CsaveMaximum )
805+ debugPrint ( "Storage capacity exceeded" )
806+ // should only happen if(CsaveMaximum) was touched on runtime.
807+ // Redimension/Deletion of Wave could be possible.
808+ return ( CsaveMaximum - 1 )
809+ endif
810+
811+ return element
801812End
802813
803814// drop first item at position 0. push all elements upward by 1 element. Free last Position.
@@ -1116,6 +1127,8 @@ End
11161127
11171128static Function setParsingTime ( numTime)
11181129 Variable numTime
1130+
1131+ debugPrint ( "parsing time:" + num2str ( numTime))
11191132 return setGlobalVar ( "parsingTime" , numTime)
11201133End
11211134
0 commit comments