Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ARRAY Help
#1
Hey im kinda new to ARRAY's but wondering if they can be used to do this...

I have a dialog and when OK is pressed it gets the text of the 5 edits and then it runs a macro to check to see if they have anything in them, well i wanna know if theres a quicker way to do it then do if(acc1 != "") do this if(acc2 != "") do this then have to type the code after each if for every box? maybe an ARRAY can do it but can someone show me an example please. Thanks....Here are my macs...

Dialog: Dialog4
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 107 103 "TEST DIALOG"
;1 Button 0x54030001 0x4 6 88 48 14 "OK"
;2 Button 0x54030000 0x4 54 88 48 14 "Cancel"
;3 Edit 0x54030080 0x200 6 4 96 14 ""
;4 Edit 0x54030080 0x200 6 20 96 14 ""
;5 Edit 0x54030080 0x200 6 36 96 14 ""
;6 Edit 0x54030080 0x200 6 52 96 14 ""
;7 Edit 0x54030080 0x200 6 68 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""


str controls = "3 4 5 6 7"
str e3 e4 e5 e6 e7
if(!ShowDialog("Dialog4" &Dialog4 &controls)) ret

ret
;messages
if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)

sel message
,case WM_INITDIALOG
,,str+ acc1 acc2 acc3 acc4 acc5
,,acc1 = ""
,,acc2 = ""
,,acc3 = ""
,,acc4 = ""
,,acc5 = ""
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,,acc1.getwintext(id(3 hDlg))
,,acc1.getwintext(id(4 hDlg))
,,acc1.getwintext(id(5 hDlg))
,,acc1.getwintext(id(6 hDlg))
,,acc1.getwintext(id(7 hDlg))
,,mac "EXAMPLE"
,case IDCANCEL DT_Cancel hDlg
ret 1

Function: EXAMPLE
Code:
Copy      Help
if(acc1 != "")
,;code here
,;code here
,;code here
,;code here
if(acc2 != "")
,;same code here
,;same code here
,;same code here
,;same code here
if(acc3 != "")
,;same code here
,;same code here
,;same code here
,;same code here
if(acc4 != "")
,;same code here
,;same code here
,;same code here
,;same code here
if(acc5 != "")
,;same code here
,;same code here
,;same code here
,;same code here


Attached Files
.qml   EXAMPLE_ARRAY.qml (Size: 1.75 KB / Downloads: 301)
#2
Code:
Copy      Help
;Instead of

str+ acc1 acc2 acc3 acc4 acc5

;use

ARRAY(str)+ g_aacc.create(5)

;Then in the function

int i
for i 0 g_aacc.len
,str& s=g_aacc[i]
,;the code, using s instead of acc1 etc
,

In the dialog function, instead of acc1, acc2 etc use g_aacc[0], g_aacc[1], etc.
#3
Hmm i dont really understand where your going?? can you fill it in my Example's so it will work and ill take a look please Thanks.
#4
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 107 103 "TEST DIALOG"
;1 Button 0x54030001 0x4 6 88 48 14 "OK"
;2 Button 0x54030000 0x4 54 88 48 14 "Cancel"
;3 Edit 0x54030080 0x200 6 4 96 14 ""
;4 Edit 0x54030080 0x200 6 20 96 14 ""
;5 Edit 0x54030080 0x200 6 36 96 14 ""
;6 Edit 0x54030080 0x200 6 52 96 14 ""
;7 Edit 0x54030080 0x200 6 68 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""


str controls = "3 4 5 6 7"
str e3 e4 e5 e6 e7
if(!ShowDialog("Dialog4" &Dialog4 &controls)) ret

ret
;messages
if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)

sel message
,case WM_INITDIALOG
,ARRAY(str)+ g_aacc.create(5)
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,,g_aacc[0].getwintext(id(3 hDlg))
,,g_aacc[1].getwintext(id(4 hDlg))
,,g_aacc[2].getwintext(id(5 hDlg))
,,g_aacc[3].getwintext(id(6 hDlg))
,,g_aacc[4].getwintext(id(7 hDlg))
,,mac "EXAMPLE"
,,DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

Code:
Copy      Help
int i
for i 0 g_aacc.len
,str& s=g_aacc[i]
,if(!s.len) continue
,;code here
,;code here
,;code here
,;in the code, replace acc1, acc2 and others to s
#5
Ok Thanks i think i got it Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)