1 Reply Latest reply on Mar 30, 2012 4:13 PM by LaRetta

    UltraLog custom Function - Deciphering

    ian.moree

      Hello All; i am starting to see that breaking down a calculation involves , Context; what parameters it is expecting and a few other nuances.

       

      I have tried to break it down as best i could; i am sure an expert will tell me otherwise , but at least i understand more everytime.

       

      hope someone enjoys.

       

       

      // SYNTAX: UltraLog ( LogField; ModTime; FieldsToLog )

       

      Case(

      ValueCount(FieldsToLog) and not $ClearLogPermit;

       

      //$ClearLogPermit and FieldstoLog are being passed via the call

      // here is script call

      //

      Let([

       

      $ClearLogPermit = 0;

      PrepData = UltraLog( ""; UltraLog::ModStamp; "TheText¶TheText[2]¶TheNumber¶TheDate¶TheTime");

      $ClearLogPermit = 1];

      PrepData

      )

      // end of script call

       

       

      // If ( the Count of Values and $clearlogPermit Not enabled (0))

      // lets start the action

       

      Let([

      Fnm = GetValue (FieldsToLog; 1);

       

      // get the value of 1st entry of Fields to Log

       

      Pref = Position (LogField; " " & Fnm & " "; 1; 1);

       

      // Get the position in LogField (text); space ; search for Fnm ; start @ 1; find 1st occurrence

       

      Pst = Position(LogField; " -» "; Pref; 1) + 4;

       

      // Look for -» in Logfiedl ; find the 1st occurence +4 to that

      // what this looks like is it goes 1 increment further (_-»_)

       

      Pnd = Position(LogField & ¶; ¶; Pref; 1);

       

      // Find ¶ in Logfield¶ ; start @ Pref and find the 1st Occurrence

       

      Pval = If(Pref; Middle(LogField; Pst; Pnd - Pst); "[---]");

       

      // If Pref evaluates to true then find in LogField; start @ Pst (5); Pnd-Pst/ else/ return [---]

      // Middle ( text; start; numberchars)

       

      Fval = GetField(Fnm);

       

      // GetField ( Fnm) -- FieldsToLog input need to be in a return delim. list

      // TheDate¶theNum¶TheText¶thePaint

       

      Sval = Substitute(Fval; ¶; "‡");

      // Substitutes Pilcrow chars with † to make it original

       

      Nval = If(Length(Fval); Sval; "[null]");

      // returns null if no value in Fval

       

      vInit = Pref = 0 and IsEmpty(Fval);

      //vInit = Pref and that = 0 and if FVal is empty then evaluate this calc

       

      Prep = Exact($ClearLogPermit; "0");

      // Evaluates to true if $ClearLogPermit is set

      // this is called via script let statement

       

       

      //we know what this is

       

       

      If(

      not Exact ( Pval; Nval ) and not vInit;

       

      TextStyleAdd(TextColor( GetAsDate(MTm) & " " & GetAsTime(MTm) &

      " " & If ( Prep; "[Log Prep]"; Get(AccountName)) & " " &

      Fnm & " " & Pval & " -» " & Nval & ¶; Prep*11776947); Prep*Italic)) &

      UltraLog(LogField; ModTime; RightValues(FieldsToLog; ValueCount(FieldsToLog) - 1))

       

      );

       

      LogField

       

      )

       

       

       

       

       

      -ian