lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Quintiq file version 2.0
#parent: #root
Method PTF_ValidateStatement (
  String action,
  structured[String] parameters
) as String id:Method_LibPTF_dlgCreateEditTestScript_PTF_ValidateStatement
{
  #keys: '[103546.0.109833699]'
  Body:
  [*
    // Checks the statement with various validation based on the action
    errormsg  := ""
    paramsize := parameters.Size();
    
    // No parameters
    if( action = LibPTF_StandardAction::AutoClose()
        or action = LibPTF_StandardAction::CloseAllForms()
        or action = LibPTF_StandardAction::EndLoop()
        or action = LibPTF_StandardAction::ProfilerStart()
      )
    {
      errormsg := this.PTF_ValidateParametersSize( action, paramsize, 0 );
    }
    // Exactly one parameter
    else if( action = LibPTF_StandardAction::OpenView()
             or action = LibPTF_StandardAction::Loop()
           )
    {
      errormsg := this.PTF_ValidateParametersSize( action, paramsize, 1 );
    
      if( errormsg.Length() = 0 and action = LibPTF_StandardAction::Loop() )
      {
        errormsg := this.PTF_ValidateGreaterThanZeroInteger( action, parameters.Element( 0 ), 1 );
      }
    }
    // Exactly two parameter
    else if( action = LibPTF_StandardAction::ScrollGCToBottom()
             or action = LibPTF_StandardAction::ScrollGCToNow()
             or action = LibPTF_StandardAction::ScrollGCToTop()
             or action = LibPTF_StandardAction::ScrollListToLast()
             or action = LibPTF_StandardAction::Wait()
           )
    {
      errormsg := this.PTF_ValidateParametersSize( action, paramsize, 2 );
    
      // This whole block will be executed if action = "Wait"
      if( action = LibPTF_StandardAction::Wait() )
      {
        if( errormsg.Length() = 0 )
        {
          errormsg := this.PTF_ValidatePositiveNumericValue( action, parameters.Element( 0 ), 1 );
    
          if( errormsg.Length() = 0 )
          {
            errormsg := this.PTF_ValidatePositiveNumericValue( action, parameters.Element( 1 ), 2 );
          }
        }
        else
        {
          custommsg := 'Action "' + action + '" should have 1 or 2 parameters. Found ' + [String]paramsize + ' instead.' + String::NewLine();
          errormsg := this.PTF_ValidateParametersSizeShowCustomMsg( action, paramsize, 1, custommsg );
    
          if( errormsg.Length() = 0 )
          {
            errormsg := this.PTF_ValidatePositiveNumericValue( action, parameters.Element( 0 ), 1 );
          }
        }
      }
    }
    // Exactly three parameters
    else if( action = LibPTF_StandardAction::ScrollGCLeftRight()
             or action = LibPTF_StandardAction::ScrollGCPageLeftRight()
             or action = LibPTF_StandardAction::ScrollGCPageUpDown()
             or action = LibPTF_StandardAction::ScrollGCUpDown()
             or action = LibPTF_StandardAction::SelectListFrom()
             or action = LibPTF_StandardAction::ZoomGC()
           )
    {
      errormsg := this.PTF_ValidateParametersSize( action, paramsize, 3 );
    
      if( errormsg.Length() = 0 )
      {
        if( action = LibPTF_StandardAction::SelectListFrom() )
        {
          errormsg := this.PTF_ValidatePositiveInteger( action, parameters.Element( 2 ), 3 );
        }
        // Other actions: "ScrollGCLeftRight", "ScrollGCPageLeftRight", "ScrollGCPageUpDown", "ScrollGCUpDown", "ZoomGC"
        else
        {
          errormsg := this.PTF_ValidateInteger( action, parameters.Element( 2 ), 3 );
        }
      }
    }
    // Zero or one parameter
    else if( action = LibPTF_StandardAction::ProfilerReset()
             or action = LibPTF_StandardAction::ProfilerStop()
           )
    {
      errormsg := this.PTF_ValidateParametersWithOptionalParamSize( action, paramsize, 0, 1 );
    }
    
    return errormsg;
  *]
}