rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on February 08, 2010, 10:32:08 PM

Title: more parF()
Post by: Mars on February 08, 2010, 10:32:08 PM
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;

Title: more parF()
Post by: rejetto on February 10, 2010, 12:33:03 AM
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).