logic and organization (O4W)
At 16 APR 2012 06:33:55PM jackie jones wrote:
I just cannot get this to work. I must have it backwards but have been working with it a very long time.
Can anyone see what I'm doing wrong?
This calls a popup O4W program as a popup which shows a list of products, the user selects one, it writes to a file, then when closed, the idea is the original program reads from the file then shows the product answer. The only problem is, it shows the one that was selected Last time, not This time. So I must have things out of order but I don't know how to get them in order.
Subroutine O4W_MYUPDATE3(CtlEntId, Event, Request)
$Insert O4WEquates
textReplace=O4WResponseOptions("1")
OPEN 'TERRS' TO TERRS ELSE O4WError("cant open terrs");RETURN
*
Begin Case
Case event _eqc "CREATE"
O4WForm()
O4WHeader("Header name)", 4)
O4WTitle("myupdate test")
*
O4WSectionStart("products")
O4WTableStart("getproducts")
O4WSetCell(1,1)
O4WText("Product Code")
O4WSetCell(1,2)
O4WTextbox("","PROD")
O4WSetCell(4,1)
O4WButton("Find Product","BTN_FINDPROD")
O4WQualifyEvent("BTN_FINDPROD","CLICK")
O4WTableEnd("getproducts")
O4WSectionEnd("products")
*
O4WSectionStart("customers")
O4WTableStart("getcust")
O4WSetCell(1,1)
O4WText("cust code")
O4WSectionEnd("customers")
* O4WSectionStart("dialog") O4WSectionEnd("dialog") *
Case event _eqc "CLICK"
BEGIN CASE
Case ctlentid _eqc "BTN_FINDPROD"
O4WResponse()
O4WSectionStart('dialog', O4WResponseOptions():O4WMarkedOptions('1'))
O4WText("Here is some text…")
* O4WPopup("O4W_TYPEPOP3",O4W_LINKTYPE_PROGRAM$,'O4W_TYPEPOP3',
,"PROD","","","") READV PROD FROM TERRS, "MYPROD", 1 ELSE PROD=
O4WResponse() O4WUpdate("PROD",PROD,O4WResponseOptions("1")) O4WResponse() O4WDialog('dialog') O4WText("You selected ":PROD) End Case end of update the product field END Case Return 0 Thanks for any help. </QUOTE> —- === At 16 APR 2012 06:49PM bshumsky wrote: === <QUOTE> <QUOTE>I just cannot get this to work. I must have it backwards but have been working with it a very long time. Can anyone see what I'm doing wrong? This calls a popup O4W program as a popup which shows a list of products, the user selects one, it writes to a file, then when closed, the idea is the original program reads from the file then shows the product answer. The only problem is, it shows the one that was selected Last time, not This time. So I must have things out of order but I don't know how to get them in order. Subroutine O4W_MYUPDATE3(CtlEntId, Event, Request) $Insert O4WEquates textReplace=O4WResponseOptions("1") OPEN 'TERRS' TO TERRS ELSE O4WError("cant open terrs");RETURN * Begin Case Case event _eqc "CREATE" O4WForm() O4WHeader("Header name)", 4) O4WTitle("myupdate test") * O4WSectionStart("products") O4WTableStart("getproducts") O4WSetCell(1,1) O4WText("Product Code") O4WSetCell(1,2) O4WTextbox("","PROD") O4WSetCell(4,1) O4WButton("Find Product","BTN_FINDPROD") O4WQualifyEvent("BTN_FINDPROD","CLICK") O4WTableEnd("getproducts") O4WSectionEnd("products") * O4WSectionStart("customers") O4WTableStart("getcust") O4WSetCell(1,1) O4WText("cust code") O4WSectionEnd("customers") *O4WSectionStart("dialog")
O4WSectionEnd("dialog")
* Case event _eqc "CLICK" BEGIN CASE Case ctlentid _eqc "BTN_FINDPROD" O4WResponse() O4WSectionStart('dialog', O4WResponseOptions():O4WMarkedOptions('1')) O4WText("Here is some text…") *
O4WPopup("O4W_TYPEPOP3",O4W_LINKTYPE_PROGRAM$,'O4W_TYPEPOP3',
,"PROD","","","") READV PROD FROM TERRS, "MYPROD", 1 ELSE PROD=
O4WResponse()
O4WUpdate("PROD",PROD,O4WResponseOptions("1"))
O4WResponse()
O4WDialog('dialog')
O4WText("You selected ":PROD)
End Case
end of update the product field
END Case
Return 0
Thanks for any help.
Hi, Jackie. When you program in O4W, the commands that you use to generate the HTML, javascript, etc. don't happen as soon as they're encountered in your stored procedure; rather, O4W builds the output and then sends it to the client (ie, the browser) when you reach the RETURN statement. So your code builds the popup BUT DOESN'T DISPLAY THE POPUP YET, then continues on and reads the record from the TERRS table and builds the O4WTEXT. And _then_ it returns all that information to the browser, which displays the popup, executes all the code needed for the popup, and then displays the text that you'd specified before the popup even appeared.
If you want to read the value after the popup has completed, then you should finish your stored procedure's handling of the click event after the O4WPOPUP call, and do a RETURN there; and then wait for the RETURNVALUE event (if your popup is an OI popup converted for O4W use, or an O4W report). If it's another type of popup (like a custom o4w stored procedure, as yours appears to be), you should end your popup's code with a call to O4WPOPUPRETURN(<value>) [where <value> is the value you want to return via the RETURNVALUE event] just before the RETURN statement.
So your code should look something like this:
Case event _eqc "CLICK"
BEGIN CASE
Case ctlentid _eqc "BTN_FINDPROD"
O4WResponse()
O4WSectionStart('dialog', O4WResponseOptions():O4WMarkedOptions('1'))
O4WText("Here is some text…")
*
O4WPopup("O4W_TYPEPOP3",O4W_LINKTYPE_PROGRAM$,'O4W_TYPEPOP3',,"PROD","","","")
end case
end of update the product field
case event _eqc "RETURNVALUE"
* NOTE: you don't really need to read this, you can get it from PROD = O4WGetValue("o4wValue")
READV PROD FROM TERRS, "MYPROD", 1 ELSE PROD=
O4WResponse()
O4WUpdate("PROD",PROD,O4WResponseOptions("1"))
O4WResponse()
O4WDialog('dialog')
O4WText("You selected ":PROD)
End Case
- Bryan Shumsky
Revelation Software, Inc.
</QUOTE>
—-
=== At 16 APR 2012 08:35PM jackie jones wrote: ===
<QUOTE>Thanks Bryan.
Could you give a short example where you show text and a textbox,
then a button that runs a popup generated by the Regular OI
and then populates the textbox?
</QUOTE>
—-
=== At 16 APR 2012 09:26PM jackie jones wrote: ===
<QUOTE>Bryan, Never mind, I got it!
Thanks for all your help.
Thanks - Jackie
</QUOTE>
View this thread on the Works forum...