'Get-values from a html form in a for/do loop

I have a problem with get-value() method in progress4GL. I am trying to get all values from html form.

My Progress4GL Code looks like:

for each tt:
  do k = 1 to integer(h-timeframe):   
        h-from  [k]  = get-value(string(day(tt.date)) + "#" + string(tt.fnr) + "#" + string(tt.pnr) + "_von"  + string(k)).
        h-to    [k]  = get-value(string(day(tt.date)) + "#" + string(tt.fnr) + "#" + string(tt.pnr) + "_bis"  + string(k)).
        h-code  [k]  = get-value(string(day(tt.date)) + "#" + string(tt.fnr) + "#" + string(tt.pnr) + "_code" + string(k)).
  end.    
end.
  • h-timeframe is parameter and could be max. 10. (1-10)

  • tt is a temp-table and represents a week(fix 7 days)

It works perfectly till 9.Parameter. If I choose the 10 (which is max) then I get some performance Problem using get-value() Function.

Example when h-timeframe = 10: enter image description here

as you can see from one get-value to another It takes really long time.( h-timeframe = 10 )

Example when h-timeframe = 9: enter image description here

and here way much faster than other.

Can anyone explain why ? It is really strange and I have no Idea.

p.s: I have this problem just at 10. 0-9 It works perfectly



Solution 1:[1]

The performance difference is probably something external to your code snippet but, for performance, I would write it more like this:

define variable d as integer   no-undo.
define variable n as integer   no-undo.
define variable s as character no-undo.

for each tt:

  // avoid recalculating and invoking functions N times per TT record

  assign
    d = day( tt.date )
    n = integer( h-timeframe )
    s = substitute( "&1#&2#&3_&&1&&2", d, tt.fnr, tt.pnr )
  .

  do k = 1 to n:

    // consolidate multiple repeated operations, eliminate STRING() calls

    assign
      h-from [k] = get-value( substitute( s, "von",  k ))
      h-to   [k] = get-value( substitute( s, "bis",  k ))  
      h-code [k] = get-value( substitute( s, "code", k ))  
    .

  end.    
end.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1