× Discuss on any other topics

manage Operande selection in Nofile routine

  • souaresalif
  • souaresalif's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 5 months ago #14115 by souaresalif
manage Operande selection in Nofile routine was created by souaresalif
Hi
I want to know how to manage Operand criteria (LK EQ RG) in nofile routine.
thx to help me

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #14118 by jpb
In general these are the steps, not managing the new criterias from browser !
$INSERT I_ENQUIRY.COMMON

CHECK.CRIT:
    CHECKS.OK=1
    PAR.CNT = DCOUNT(D.FIELDS,FM)
    FOR PAR.I=1 TO PAR.CNT
        PAR.NAME  = D.FIELDS<PAR.I>
        LOCATE PAR.NAME IN ENQ.FIELD.NAMES<1> SETTING FLD.POS ELSE CONTINUE
        FLD.VAL   = ELEM<1,FLD.POS>
        PAR.VAL   = D.RANGE.AND.VALUE<PAR.I>
        CONVERT SM TO FM IN PAR.VAL
        PAR.OPRND = D.LOGICAL.OPERANDS<PAR.I>
        GOSUB CHECK.PAR
        IF CHECKS.OK=0 THEN RETURN
    NEXT PAR.I
    RETURN

CHECK.PAR:
* set result to false
    CHECKS.OK = 0

    BEGIN CASE
* equal
    CASE PAR.OPRND=1
        LOCATE FLD.VAL IN PAR.VAL<1> SETTING POS ELSE RETURN
* range
    CASE PAR.OPRND=2
        IF FLD.VAL<PAR.VAL<1> OR FLD.VAL>PAR.VAL<2> THEN RETURN
* less than
    CASE PAR.OPRND=3
        IF FLD.VAL>=PAR.VAL<1> THEN RETURN
* greater than
    CASE PAR.OPRND=4
        IF FLD.VAL<=PAR.VAL<1> THEN RETURN
* not equal
    CASE PAR.OPRND=5
        PAR.VAL.TMP = PAR.VAL
        CONVERT @FM TO @VM IN PAR.VAL.TMP
        IF FLD.VAL MATCHES PAR.VAL.TMP THEN RETURN
* like
    CASE PAR.OPRND=6
        EXPR.A=FLD.VAL
        EXPR.B=PAR.VAL<1>
        GOSUB A.LIKE.B
        RETURN
* unlike
    CASE PAR.OPRND=7
        EXPR.A=FLD.VAL
        EXPR.B=PAR.VAL<1>
        GOSUB A.LIKE.B
        IF CHECKS.OK=0 THEN CHECKS.OK=1 ELSE CHECKS.OK=0
        RETURN
* less than or equal
    CASE PAR.OPRND=8
        IF FLD.VAL>PAR.VAL<1> THEN RETURN
* greater than or equal
    CASE PAR.OPRND=9
        IF FLD.VAL<PAR.VAL<1> THEN RETURN
* not range
    CASE PAR.OPRND=10
        IF FLD.VAL>=PAR.VAL<1> AND FLD.VAL<=PAR.VAL<2> THEN RETURN
    END CASE

    CHECKS.OK = 1

    RETURN
***************
A.LIKE.B:
    LOOP
        DOTS.POS = INDEX(EXPR.B,"...",1)
    WHILE DOTS.POS <> 0 DO
        IF DOTS.POS = 1 THEN
            EXPR.B=EXPR.B[4,999]
            IF EXPR.B="" THEN EXIT
            DOTS.POS=INDEX(EXPR.B,"...",1)
            IF DOTS.POS=0 THEN
                IF RIGHT(EXPR.A,LEN(EXPR.B)) = EXPR.B THEN CHECKS.OK=1 ELSE CHECKS.OK=0
                RETURN
            END
            B.PREF=EXPR.B[1,DOTS.POS-1]
            A.POS=INDEX(EXPR.A,B.PREF,1)
            IF A.POS=0 THEN
                CHECKS.OK=0
                RETURN
            END
            EXPR.A=EXPR.A[A.POS+LEN(B.PREF),999]
            EXPR.B=EXPR.B[LEN(B.PREF)+1,999]
            IF EXPR.B="" THEN EXIT
        END ELSE
            B.PREF=EXPR.B[1,DOTS.POS-1]
            IF EXPR.A[1,DOTS.POS-1] <> B.PREF THEN
                CHECKS.OK = 0
                RETURN
            END
            EXPR.A=EXPR.A[DOTS.POS,999]
            EXPR.B=EXPR.B[DOTS.POS,999]
        END
    REPEAT

    IF EXPR.B="" OR EXPR.A=EXPR.B THEN CHECKS.OK=1 ELSE CHECKS.OK=0

    RETURN
The following user(s) said Thank You: armin

Please Log in or Create an account to join the conversation.

  • mounisarma
  • Visitor
  • Visitor
10 years 8 months ago #15789 by mounisarma
Replied by mounisarma on topic manage Operande selection in Nofile routine
Hi Jpb,

is there any routine sample to handle the operands (17) in browser?
Please share the logic if it is available.

Thanks,
Sarma.

Please Log in or Create an account to join the conversation.

More
10 years 8 months ago - 10 years 8 months ago #15791 by jpb
The "new" browser operands that I know are

11 = CT - contains
12 = NC - contains not
13 = BW - begins with
14 = EW - ends with

and can be handled analog to like / unlike

As the insert I_ENQ.MATCH.FIELD (that can be used instead of the above code ) handles only 1 - 10 I don't have a sample ;-)
Last edit: 10 years 8 months ago by jpb.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds