Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Quintiq file version 2.0
#parent: #root
Method PTF_ValidateScript (
  String script
) as String id:Method_LibPTF_dlgCreateEditTestScript_PTF_ValidateScript
{
  #keys: '[103546.0.109833688]'
  Body:
  [*
    // Checks the script with various validation
    scriptwithoutcomment := this.PTF_RemoveComment( script );
    rows                 := scriptwithoutcomment.Tokenize( String::NewLine() );
    rownr                := 0;
    errormsg             := "";
    
    traverse( rows, Elements, row, errormsg.Length() = 0 )
    {
      parameters := null( Strings );
      rownr++;
    
      row := row.TrimBoth();
    
      if( row.Length() > 0 )
      {
        // Line by line basic validation
        row      := row.ReplaceAll( ";", "" );
        action   := this.PTF_GetActionAndParameters( row, parameters );
        errormsg := this.PTF_ValidateStatement( action, parameters );
      }
    }
    
    if( errormsg.Length() > 0 )
    {
      errormsg := "Line #" + [String]rownr + ": " + errormsg;
    }
    else
    {
      // Validation considering more than just the line itself
      errormsg := this.PTF_ValidateComment( scriptwithoutcomment );
    
      if( errormsg.Length() = 0 )
      {
        errormsg := this.PTF_ValidateLoop( scriptwithoutcomment );
      }
    }
    
    return errormsg;
  *]
}