rejetto forum

more parF()

Mars · 2 · 3477

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Minor but possible update

    if name = 'round' then
      result:=floatToStr(roundTo(parF(0), -parI(1, 0)));

    if name = 'set speed limit for address' then
      with objByIp(p) do
        try
          limiter.maxSpeed:=round(parF(1)*1000);
          customizedLimiter:=TRUE;
        except end;

    if name = 'set speed limit for connection' then
      if satisfied(md.cd) then
        try
          md.cd.limiter:=TspeedLimiter.create(round(parF(0)*1000));
          md.cd.conn.limiters.add(md.cd.limiter);
          srv.limiters.add(md.cd.limiter);
        except end;

    if name = 'in range' then
      try trueIf(inRange(parF(1), parF(1), parF(2)))
      except result:='' end;



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
yes, i applied this suggestion, but maybe you are missing something.
the original version of parF(n) does not throw any exception, while stroToFloat() does.

those "try"s you see in the code are there exactly because of that.
but parF() is handy, and i'd like to use it also in cases where exception must be thrown.
i came to this:
all parF(n) will throw exception
while parF(n,n) will not (to be used where it is not needed).