Rocket OpenQM

 View Only
  • 1.  GETLIST(V) Bug in OpenQM

    PARTNER
    Posted 10-03-2023 11:16

    I have reported this to support but wondered if a) anyone else has seen this issue, and b) warn those of you that may be unaware of it.

    The GETLIST or GETLISTV statement in QM Basic (not to be confused with GET-LIST from TCL) uses the syntax:

    GETLIST "LISTNAME" TO MY.LIST SETTING CNT ELSE whatever....

    The SETTING CNT is what's broken here. Rather than return the count of items in LISTNAME it returns the count of the most recent active select list you may have had - even though it's no longer active. You can test this quite simply by writing a program such as:

    PRINT "Listname: ":
    INPUT LNAME
    GETLIST LNAME TO MY.LIST SETTING CNT ELSE STOP
    CRT "Record Count: ":CNT
    FOR I = 1 TO CNT
       CRT MY.LIST<I>
    NEXT I

    If you compile / catalog that, then create yourself a savelist with 1 or 2 items in it then log off. Log back in you will be in a new session that has never had an active select list. Run the program, give it your listname and instead of the expected "Record Count: 2" and showing you the two ID's you will get a "Record Count: 0" and no IDs displayed.

    Now SELECT a file you know has data - assuming SELECT CUSTOMER and you get 1000 records. Immediately CLEARSELECT so you don't have an active list and re-run the program and you will get: "Record Count: 1000" and it will proceed to loop 1000 times but display the 2 id's from your actual list.

    The work around is simple - don't use SETTING CNT and use CNT = DCOUNT(MY.LIST,@AM) instead. Amazingly you can't use READNEXT ID ELSE EXIT as it will keep going for all 1000 times reading null into ID. This caused us some heartburn today so thought I'd share.

    Happy coding!

    Justin



    ------------------------------
    Justin Orton
    Owner, Solution Architect
    Technical Plus LLC
    kissimmee FL US
    ------------------------------