Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User Input from dialogue
#1
Having trouble passing variables from a dialogue to a function.

I tried making one on my own, and it works but the dialogue closes on click. I need it to stay open and keep the current info.  (If ret 0, it doesn't copy the info to the program, but it will stay open.)
Code:
Copy      Help
int MOM=win("Multichannel Order Manager" "momwin9c000000")
DateTime t.FromComputerTime
str PipDate=t.ToStrFormat("{MM/dd/yy}")

str Order
str iDate
str User
str TrkInv
str Note

str dd=
BEGIN DIALOG
0 "" 0x90C80AC8 0x0 0 0 168 106 "EZ Main PO"
10 Static 0x54000000 0x0 23 96 122 12 "Press Pause on keyboard if stuck."
3 ComboBox 0x54230243 0x0 24 20 120 213 ""
4 Static 0x54000000 0x0 36 56 20 12 "Date"
5 Edit 0x54030080 0x200 56 56 56 12 "Date"
6 Static 0x54000000 0x0 8 40 48 12 "Tracking\Inv#"
7 Edit 0x54030080 0x200 56 40 88 12 "TrkInv"
8 ComboBox 0x54230243 0x0 48 4 96 213 ""
9 Static 0x54000000 0x0 24 4 24 13 "User:"
11 Button 0x54032000 0x0 40 72 88 22 "Send to MOM"
END DIALOG
DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "3 5 7 8"
str cb3 e5Dat e7Trk cb8
cb8=
&NJB
TAM
PIP
TJW
cb3=
&Open Order Report Sent
Received PO Confirmation
Invoiced
ETA Set
Shipped
Delivered
Received
Closing when
e5Dat=PipDate
if(!ShowDialog(dd &sub.DlgProc &controls)) ret

Order=cb3                    ;;Which step?
iDate=e5Dat                ;;Entered Date
User=cb8                    ;;Which user?
TrkInv=e7Trk                ;;Tracking number?
User.replacerx(".* (...).*" "$1")    ;;extract CB info from username

    act MOM                                ;;Focus on MOM window
    wait 3 S "image:hCA397E48" MOM 0 16|128     ;;Verify open PO screen, otherwise error
    Acc a.Find(MOM "TEXT" "txtReference" "state=0x100000 0x20000040" 0x1085)
    a.Select(3)                                ;;select note field
    'CaX                                    ;;clear notes
    if Order="0 Open Order Report Sent"
        Note=F"O: {iDate} {User}"
    if Order="1 Received PO Confirmation"
        Note=F"C: {iDate} {User}"
    if Order="2 Invoiced"
        Note=F"I: {TrkInv} {iDate} {User}"
    if Order="3 ETA Set"
        Note=F"ETA: {iDate} {User}"
    if Order="4 Shipped"
        Note=F"S: {TrkInv} {iDate} {User}"
    if Order="5 Delivered"
        Note=F"D: {iDate} {User}"
    if Order="6 Received"
        Note=F"Rcvd: {iDate} {User}"
    if Order="7 Closing when"
        Note=F"X: {iDate} {User}"
    Note.replacerx("(.........................).*" "$1")            ;;note field only 25 characters long
    key (Note)



#sub DlgProc
function# hDlg message wParam lParam

sel message
    case WM_INITDIALOG
    case WM_DESTROY
    case WM_COMMAND goto messages2
ret
messages2
sel wParam
    case 11
    ret 1
    case IDCANCEL
ret 1
So i loaded up your sample ["On button click" dlg_button1] and used it as a base since it stays open on button click... but it works differently\backwards. I have to load the CB info before the dialog or else they will be blank.. The code between 'END DIALOG' and '>messages' seems to be ignored? (The strings aren't copied, and the 'out Order' and 'out "test" ' do not display)
Code:
Copy      Help
function# hDlg message wParam lParam
int MOM=win("Multichannel Order Manager" "momwin9c000000")
DateTime t.FromComputerTime
str PipDate=t.ToStrFormat("{MM/dd/yy}")
str Order
str iDate
str User
str TrkInv
str Note

if(hDlg) goto messages

str controls = "5 7 9 11"
str cb5Ini cb7Ste e9Trk e11Dat

cb5Ini=
&NJB
TAM
PIP
TJW
cb7Ste=
&Open Order Report Sent
Received PO Confirmation
Invoiced
ETA Set
Shipped
Delivered
Received
Closing when
e11Dat=PipDate

if(!ShowDialog("cpt_log" &cpt_log &controls)) ret

BEGIN DIALOG
0 "" 0x90C80AC8 0x0 0 0 160 120 "Dialog"
3 Button 0x54032000 0x0 24 80 112 24 "Send to MOM"
4 Static 0x54000000 0x0 8 8 24 12 "Initials"
5 ComboBox 0x54230243 0x0 40 8 112 213 "Initials"
6 Static 0x54000000 0x0 8 24 24 12 "Step"
7 ComboBox 0x54230243 0x0 40 24 112 213 "Step"
8 Static 0x54000000 0x0 8 40 24 12 "Trk\Inv"
9 Edit 0x54030080 0x200 40 40 112 12 "TrkInv"
10 Static 0x54000000 0x0 8 56 24 12 "Date"
11 Edit 0x54030080 0x200 40 56 112 12 "Date"
END DIALOG
DIALOG EDITOR: "" 0x2040700 "" "" "" ""

Order=cb7Ste                ;;Which step
iDate=e11Dat                ;;Copy user input date (or current date if they didn't change it)
User=cb5Ini                ;;Which user?
TrkInv=e9Trk                ;;Tracking number?
User.replacerx(".* (...).*" "$1")    ;;extract user initials from CB info
out Order
out "test"

ret
messages
sel message
    case WM_INITDIALOG
    case WM_DESTROY
    case WM_COMMAND goto messages2
ret
messages2
sel wParam
    case 3
    out "case3"
    act MOM                            ;;Focus on MOM window
    wait 0.2
    scan "image:hB69CFF5D" MOM 0 2|16        ;;verify open PO
    Acc a.Find(MOM "TEXT" "txtReference" "state=0x100000 0x20000040" 0x1085)
    a.Select(3)
    'CaX
    if Order="0 Open Order Report Sent"
        Note=F"O: {iDate} {User}"
    if Order="1 Received PO Confirmation"
        Note=F"C: {iDate} {User}"
    if Order="2 Invoiced"
        Note=F"I: {TrkInv} {iDate} {User}"
    if Order="3 ETA Set"
        Note=F"ETA: {iDate} {User}"
    if Order="4 Shipped"
        Note=F"S: {TrkInv} {iDate} {User}"
    if Order="5 Delivered"
        Note=F"D: {iDate} {User}"
    if Order="6 Received"
        Note=F"Rcvd: {iDate} {User}"
    if Order="7 Closing when"
        Note=F"X: {iDate} {User}"
    Note.replacerx("(.........................).*" "$1")        ;;limit note to 25 char
    key (Note)
    
    
    case IDOK
    out "OK"
    
    case IDCANCEL
ret 1


3 and 4 are button id, as specified in text in BEGIN DIALOG ... END DIALOG

i have been looking through the forum and trying to fix this for days before building up the nerve to ask for help.
(also, im sure my code is horrendous. sorry)
Any input would be greatly appreciated as i obviously have no idea what i'm doing.
-Pip
#2
Macro Macro2971
Code:
Copy      Help
int MOM=win("Multichannel Order Manager" "momwin9c000000")
DateTime t.FromComputerTime
str PipDate=t.ToStrFormat("{MM/dd/yy}")

str Order
str iDate
str User
str TrkInv
str Note

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 168 106 "EZ Main PO"
;10 Static 0x54000000 0x0 23 96 122 12 "Press Pause on keyboard if stuck."
;3 ComboBox 0x54230243 0x0 24 20 120 213 ""
;4 Static 0x54000000 0x0 36 56 20 12 "Date"
;5 Edit 0x54030080 0x200 56 56 56 12 "Date"
;6 Static 0x54000000 0x0 8 40 48 12 "Tracking\Inv#"
;7 Edit 0x54030080 0x200 56 40 88 12 "TrkInv"
;8 ComboBox 0x54230243 0x0 48 4 96 213 ""
;9 Static 0x54000000 0x0 24 4 24 13 "User:"
;11 Button 0x54032000 0x0 40 72 88 22 "Send to MOM"
;12 Button 0x54032000 0x0 136 72 24 22 "End"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""
str controls = "3 5 7 8"
str cb3 e5Dat e7Trk cb8
cb8=
;&NJB
;TAM
;PIP
;TJW
cb3=
;&Open Order Report Sent
;Received PO Confirmation
;Invoiced
;ETA Set
;Shipped
;Delivered
;Received
;Closing when
e5Dat=PipDate
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 11
,DT_GetControls hDlg
,EnableWindow lParam 0
,opt waitmsg 1
,int-- t_thread
,t_thread=mac("sub.Macro" "" cb3 e5Dat e7Trk cb8)
,wait 0 H t_thread
,t_thread=0
,EnableWindow lParam 1
,
,case 12
,if(t_thread) EndThread "" t_thread
ret 1


#sub Macro
function str'Order str'iDate str'TrkInv str'User

out
out Order
out iDate
out TrkInv
out User

spe -1
mes "macro"

Not the simplest version, but I would do it like this. The macro runs in other thread. Simpler would be to run in dialog's thread, with opt waitmsg 1.

I placed the macro in #sub Macro, but you can move the code to a separate macro and use its name instead of "sub.Macro". Then, if the dialog itself is macro, two macros cannot run simultaneously, need to change something in the Properties dialog -> Macro properties.
#3
I also added button "End" to end the tread if the user wants to.
#4
As always, you are the greatest.
Thank you so much! It works perfectly.


Forum Jump:


Users browsing this thread: 2 Guest(s)