2

I need to update field in program a.p using external program or procedure. But i can't. This is example of a.p:

DEF VAR v1 AS CHAR.
DEF VAR v2 AS CHAR.
DEF VAR v3 AS CHAR.
DEF VAR v4 AS CHAR.

DEF VAR external_program AS CHAR INITIAL 'myexternalprogram.p'.

FORM 
    v1
    v2
    v3
    v4
WITH FRAME f1.


ON F2 OF v1 IN FRAME f1
DO:

    RUN VALUE(external_program) .

END.
REPEAT:
    UPDATE 
        v1
        v2
        v3
        v4
    WITH FRAME f1.
END.
=========================================
myexternalprogram.p :

INPUT FROM VALUE(txt_with_data).

If i am using internal procedure is very easy. But i need to use external. And i cannot modify program a.p . I tried some with handle but i failed...

I started thinking , is it possible in any way?

Thank You for Your answer.

When I use :

MESSAGE PROGRAM-NAME(2) VIEW-AS ALERT-BOX.
MESSAGE SELF:NAME VIEW-AS ALERT-BOX.

SELF:SCREEN-VALUE = 'w1'.
APPLY "ENTER" TO SELF.

I can jump to another field, but on the end of the procedure. How can I with similiar code jumping through all of my fields knowing frame and field name?

Wiktor
  • 754
  • 1
  • 7
  • 24

1 Answers1

1

You can re-direct stdin by running a batch session:

mbpro -db dbname -p program.p < input.file

Alternately, use the ENTRY event to get the current field, check it's PROGRAM-NAME() and SELF:NAME values for the field you want, and modify SELF:SCREEN-VALUE as appropriate.

To update other fields in the frame, use widget-handle:PREV-SIBLING and widget-handle:NEXT-SIBLING to walk the frame's widget tree.

Tim Kuehn
  • 3,201
  • 1
  • 17
  • 23
  • It would work, but not in case when Im using program a.p . When I have opened a.p and in the same session I need to fill this field. – Wiktor Dec 13 '13 at 15:24
  • In that case, run a persistent procedure with an ON ENTRY ANYWHERE trigger. In the trigger, check PROGRAM-NAME() to see if it's in the right program, SELF:NAME that it's in the right field, and set SELF:SCREEN-VALUE to what the field needs in it. – Tim Kuehn Dec 13 '13 at 19:01
  • You cannot modify a.p yet it contains a "hook" to call "myexternalprogram.p"? Can you modify that hook? (That seems to be what Tim is suggesting.) Or is that untouchable as well? Where, in a.p, do you want the data to appear? v1? Or somewhere else? – Tom Bascom Dec 14 '13 at 21:19
  • He's trying to change the input field's value for a program he doesn't have source to - something similar to what ProStar's TailorPro does on a larger basis. The only way to do this is to capture the ENTRY event of the UI field, and then use some logic to determine if this is the right program and field, and then fit the SCREEN-VALUE for the field to the required value. – Tim Kuehn Dec 14 '13 at 23:50
  • Yes Tim, that is exactly what i trying to do. Im using QAD software that let me hook ENTRY, LEAVE OR GO events. In my program above it is 'F2' event (because on Entry I can specify more events). – Wiktor Dec 16 '13 at 09:56
  • I need to add, that I know what is the field, frame and program name. But i dont know how to fill them in loop. This fields its not every fields in original program. But i guess i can handle with that, only knowing how to fill only one. – Wiktor Dec 16 '13 at 10:02
  • 1
    Once you've got one fields handle, you can get the rest by going prev-sibling and next-sibling to walk the frame's widget tree. – Tim Kuehn Dec 16 '13 at 23:53
  • Thank You Tim, Your answers were very helpful. Now I have handle to each field in each frame. I can set screen-value. But i have another wall in front of me. When I set screen-value, i should be abble to proceed to go to another loop of repeat in this program. Yes, and I dont know how. I tried : APPLY "GO" , "ENTER" , "RETURN" TO THIS-PROCEDURE, SELF, SOURCE-PROCEDURE, FOCUS and nothing helps. – Wiktor Dec 17 '13 at 13:37
  • Great! Can you give mark this as "answered" and give me an upvote? :) – Tim Kuehn Dec 17 '13 at 13:39
  • I edited previous post. Can You help me one again ? :) – Wiktor Dec 17 '13 at 13:45
  • Ok. I get it :) FOCUS = handleField and PAUSE 0 do the job :) – Wiktor Dec 17 '13 at 14:36
  • 1
    You should make this a new question, as it's not the same as the one you gave. You also need to upvote my answer. :) – Tim Kuehn Dec 17 '13 at 15:34
  • 1
    I really want to upvote, but i dont have requider reputation points. need to earn some to give You upvote. – Wiktor Dec 17 '13 at 15:53