In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

Vroom

As promised, the first in an occasional series with hints on getting the most from Advanced Revelation. Whilst it is generally more cost effective to put in faster hardware than spend weeks optimising software, an awareness of possible improvements is still useful. Some of the hints included here may seem obvious, but all are taken from hints delivered to experienced REV/AREV programmers recently.

Testing For a Value

It is frequently necessary when eliciting user response to ensure that the information returned is valid. This can be done in the following manner (the code is by way of example only, obviously it can be improved in other ways, popups, collectors, @LOWER.CASE etc).


0001      VALID = 0
0002      ANS = ""
0003      LOOP
0004         CALL MSG("Y/N","RC",ANS,"")
0005         IF ANS="Y" OR ANS="y" OR ANS="N" OR ANS="n" THEN
0006            VALID = 1
0007         END
0008      UNTIL VALID
0009      REPEAT

however, it can be accomplished more efficiently with the construct


0001      VALID = 0
0002      ANS = ""
0003      LOOP
0004         CALL MSG("Y/N","R",ANS,"")
0005         IF INDEX("YyNn",ANS,1) THEN VALID = 1
0006      UNTIL VALID
0007      REPEAT

This construct also has the advantage that its performance hardly degrades as the amount of comparisons increase unlike the former method. In the table below, the same comparisons were performed multiple times to evaluate the times taken for each. From this it can be seen that INDEX is quicker even if testing for a single value. (This benchmark was performed on 2.0)

    Comparisons ³  1    ³  2    ³  3    ³  4    ³  10
    ÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄ
    INDEX       ³  2.03 ³  2.08 ³  2.09 ³  2.11 ³   2.36
    IF n OR n   ³  2.25 ³  3.35 ³  4.45 ³  5.60 ³  12.14

Extracting Parts of Keys

When dealing with a two part key (or similar) it is quicker to use the FIELD function (EG PART1 = FIELD(KEY,"*",1)) than to use the [ ] syntax (EG PART1 = KEY[1,"*"]).

Selecting Records From File

When selecting records from file for subsequent processing AND THE FIELDS FORMING THE SELECTION CRITERIA ARE NOT INDEXED it is quicker to extract the required records by reading in all records and doing the required comparison in BASIC than by PERFORMing a select. I have seen the latter done at several sites visited lately and speed improvements of upto 100% have been gained by adopting the former method (depending on the complexity of he comparison criteria).

(Volume 1, Issue 10, Pages 8,9)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel