Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get which option was pressed
#1
You use CB_GetItemText to get the combo box text (or maybe you call it populate it).

Function Function4
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 7 8 9"
str cb3 o7Wan o8Wil o9No
rget cb3 "cb" "\test\test"
if(!ShowDialog("Function4" &Function4 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Name List"
;1 Button 0x54030001 0x4 2 110 48 14 "OK"
;2 Button 0x54030000 0x4 60 110 48 14 "Cancel"
;3 ComboBox 0x54230641 0x0 6 16 96 56 ""
;5 Button 0x54032000 0x0 104 16 18 14 "+"
;6 Button 0x54032000 0x0 104 32 18 14 "-"
;7 Button 0x54032009 0x0 148 6 135 12 "Wants you to call"
;8 Button 0x54002009 0x0 148 22 135 12 "Will call back"
;9 Button 0x54002009 0x0 148 38 135 12 "No message"
;4 Button 0x54020007 0x0 2 2 126 96 "Employee Names "
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5 ;;+
,str s.getwintext(id(3 hDlg))
,s.trim; if(!s.len) ret
,CB_Add id(3 hDlg) s
,;SendMessage id(3 hDlg) CB_ADDSTRING 0 s ;;use this instead of the above line if CB_Add is unavailable
,
,case 6 ;;-
,int i=CB_SelectedItem(id(3 hDlg))
,if(i<0) ret
,SendMessage id(3 hDlg) CB_DELETESTRING i 0
,
,case IDOK
,int j h=id(3 hDlg); str s1
,ARRAY(str) a
,for j 0 CB_GetCount(h)
,,CB_GetItemText h j s1
,,a[]=s1
,out a
,
,case IDCANCEL
ret 1

Is there a way to get an option (out of a group of options) such as option 1, option 2 or option 3 and put in an array? I think that this is possible because you use option first option next to group options in your dialogs. I know that my example does not work but maybe someone can give me an example that does.

Function Function5
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 7 8 9"
str cb3 o7Wan o8Wil o9No
rget cb3 "cb" "\test\test"
if(!ShowDialog("Function5" &Function5 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Name List"
;7 Button 0x54032009 0x0 10 6 135 12 "Option 1"
;8 Button 0x54002009 0x0 10 22 135 12 "Option 2"
;1 Button 0x54030001 0x4 2 110 48 14 "OK"
;2 Button 0x54030000 0x4 60 110 48 14 "Cancel"
;9 Button 0x54002009 0x0 10 38 135 12 "Option 3"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5 ;;+
,str s.getwintext(id(3 hDlg))
,s.trim; if(!s.len) ret
,CB_Add id(3 hDlg) s
,;SendMessage id(3 hDlg) CB_ADDSTRING 0 s ;;use this instead of the above line if CB_Add is unavailable
,
,case 6 ;;-
,int i=CB_SelectedItem(id(3 hDlg))
,if(i<0) ret
,SendMessage id(3 hDlg) CB_DELETESTRING i 0
,
,case IDOK
,int j h=id(3 hDlg) or h=id(4 hDlg) or h=id(5 hDlg); str s1
,ARRAY(str) a
,for j 0 GetOption(h)
,,GetOption h j s1
,,a[]=s1
,out a
,
,case IDCANCEL
ret 1
#2
Ok I have this so far;

Function Option_Array_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5"
str o3Opt o4Opt o5Opt
if(!ShowDialog("Option_Array_Dialog" &Option_Array_Dialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032009 0x0 10 8 48 12 "Option 1"
;4 Button 0x54002009 0x0 10 26 48 12 "Option 2"
;5 Button 0x54002009 0x0 10 44 48 13 "Option 3"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Macro
Code:
Copy      Help
Acc Option1=acc("Option 1" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
int Opt1=Option1.State()
Acc Option2=acc("Option 2" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
int Opt2=Option2.State()
Acc Option3=acc("Option 3" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
int Opt3=Option3.State()

ARRAY(int) a.create(3) ;;create array of integers
a[0]=Opt1 ;;set option 0 element
a[1]=Opt2 ;;set option 1 element
a[2]=Opt3 ;;set option 2 element
int el=a[0] ;;get element

if(a[0] = 16)
,mes("Option 1 was selected")
if(a[1] = 16)
,mes("Option 2 was selected")
if(a[2] = 16)
,mes("Option 3 was selected")

I have not found a way to place this in my dialog and make it work but it does work as a stand-alone macro.

I am wondering if I am wasting my time trying to learn arrays especially in this instance. I think that if I had more than three options to chouse from an array would be the right place to hold the information. I am wondering if there is an easier way to make an array for this and I will keep trying if just to find out the best way to do it.
#3
Function Option_Array_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5"
str o3Opt o4Opt o5Opt
if(!ShowDialog("Option_Array_Dialog" &Option_Array_Dialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032009 0x0 10 8 48 12 "Option 1"
;4 Button 0x54002009 0x0 10 26 48 12 "Option 2"
;5 Button 0x54002009 0x0 10 44 48 13 "Option 3"
;6 Button 0x54032000 0x0 112 8 76 32 "Check which Option"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 6
,Acc Option1=acc("Option 1" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt1=Option1.State()
,Acc Option2=acc("Option 2" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt2=Option2.State()
,Acc Option3=acc("Option 3" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt3=Option3.State()
,ARRAY(int) a.create(3) ;;create array of integers
,a[0]=Opt1 ;;set option 0 element
,a[1]=Opt2 ;;set option 1 element
,a[2]=Opt3 ;;set option 2 element
,int el=a[0] ;;get element
,out a[0]
,out a[1]
,out a[2]
,if(a[0] = 1048592)
,,mes("Option 1 was selected")
,,ret
,if(a[1] = 1048592)
,,mes("Option 2 was selected")
,,ret
,if(a[2] = 1048592)
,,mes("Option 3 was selected")
,,ret
,if(a[0] and a[1] and a[2]=1048576)
,,mes "No options were selected" "Please Pick Something" "!"
,case IDOK
,case IDCANCEL
ret 1

I don't know exactly why the numbers are not 0 and 16 for the states of the checkboxes. I did some work a while ago and that's how I discovered the 1048592
and 1048576. I think I asked Gintaras about this but didn't get an answer. Anyways, that is probably why you can't get it to work when you put it in your dialog but can when it is a stand alone macro.

I really don't think you need to use arrays here...really arrays so far for me seem to be most useful to grab large amounts of data and then break it up. Don't give up on arrays though...you will need them!
#4
Okay...so here is your example better utilizing arrays...

Function Option_Array_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5"
str o3Opt o4Opt o5Opt
if(!ShowDialog("Option_Array_Dialog" &Option_Array_Dialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032009 0x0 10 8 48 12 "Option 1"
;4 Button 0x54002009 0x0 10 26 48 12 "Option 2"
;5 Button 0x54002009 0x0 10 44 48 13 "Option 3"
;6 Button 0x54032000 0x0 112 8 76 32 "Check which Option"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 6
,int i
,Acc Option1=acc("Option 1" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt1=Option1.State()
,Acc Option2=acc("Option 2" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt2=Option2.State()
,Acc Option3=acc("Option 3" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt3=Option3.State()
,ARRAY(int) a.create(3) ;;create array of integers
,a[0]=Opt1 ;;set option 0 element
,a[1]=Opt2 ;;set option 1 element
,a[2]=Opt3 ;;set option 2 element
,int el=a[0] ;;get element
,;;This is what makes arrays cool too!!
,for(i 0 a.len)
,,if a[i] = 1048592
,,,_s.format("Option %i was selected" i+1)
,,,mes _s
,,,ret
,if(a[0] and a[1] and a[2]=1048576)
,,mes "No options were selected" "Please Pick Something" "!"
,case IDOK
,case IDCANCEL
ret 1
#5
OK arrays - not bad but it is very hard for me to understand and this part of the macro that you gave me I will not try to even pretend that I understand but I see that I like and I will try to understand it.

Macro
Code:
Copy      Help
,;;This is what makes arrays cool too!!
,for(i 0 a.len)
,,if a[i] = 1048592
,,,_s.format("Option %i was selected" i+1)
,,,mes _s
,,,ret

I do thank you for your work and I will now be able to complete that other post about the employee and the calls now.

Who do I talk to about a purchase of qm? I will probably need to use qm on many computers, At least I think unless I can make executables programs and use them on all the computers. I know very little about qm and my 30 days is about up, but I think I want to learn more.
#6
Talk to Gintaras...he's the man!
By the way...you actually end up with 45 days on the free trial. Fun little freebie!
The program is only $40 and that gives you license to use it on I think three computers.


As far as the tid bit there...

In layman's terms...
the "for" statement: "for(i 0 a.len)"
"for" is the command followed by it's flags (i 0 a.len)
"i" is the index of the items in the array. (which in this case is a[i] = a[0] on the first run, a[1] on the second, and a[2] on the third) this is known as the "counter" variable.
"0" is the index where counter starts. This is called the initial value.
"a.len" is the length of "a" or really the the number of items in the array. It is saying what value where the counter will stop running. In this case it is going to run every item in the array "a"

From the help files:
Quote:for counter initvalue finalvalue [step]
Parts
counter - counter variable. Type - int, long, or unsigned int (lpstr or pointer).
initvalue - initial counter value. Type - type of counter.
finalvalue - final counter value. Type - type of counter.
step - value to add to counter after each loop. Type - int. Default: 1.
statements - one or more statements (commands).

Anything that is in [brackets] is optional, which usually means it has a default. You can see that [step] is optional and has a default of 1. You could change this to 2. In that case in your example only the buttons "Option 1" and "Option 3" would work because the counter would go 0 (a[0] or "Option 1") then 0+2=2 (a[2] or "Option 3")

The statements encompasses the work you would like to get done to each of the items in the array.
so here it is:
if a[i] = 1048592
where in each run the index of "a" will change per counter...
on first run its really like saying:
if a[0] = 1048592
second:
if a[1] = 1048592
third:
if a[2] = 1048592

Then there is just a simple format here applied to the global string variable _s
_s.format("Option %i was selected" i+1)
whatever is in "quotations" is the text you are formatting to _s. If % is in there somewhere...that's the dynamic text that will change per variable. Here you see %i...that's what's going to change. The rest is static text. at the end where there is "i+1" that's what gets inserted for %i. In this case i=0 where the button text="Option 1" so adding 1 to i allows the message text to say..."Option 1 was selected" instead of "Option 0 was selected"

Then the "mes _s" not too hard to understand...

The "ret" tells the function to stop running...this is necessary to prevent the following from running if one of the above criteria were met.
if(a[0] and a[1] and a[2]=1048576)
,mes "No options were selected" "Please Pick Something" "!"
Go ahead and take out the "ret" and run your dialog...you'll see exactly what I mean.

Well...I hope that sheds some light on it for you. I know how much I struggled with this when I started...so I figured I'd pass what I had figured out on...Oh and by the way...Gintaras really is the man...without him, I would not have ever figured any of this out.
#7
As far as the tid bit there... I will work on this (probably for awhile) but I see the power.

Thanks for the information about the 45 day thing I am waiting to see if I can get the company that I work for to pay for it and as you know company are slow when you want to spend there money.

I went to http://www.quickmacros.com/ and I think that I would like the QM Pro. Can I use that own more than one computer?
#8
Quote:Quick Macros license agreement
You may use this software only as described in this license agreement. If you do not agree to the terms below, do not install or use the software. Here "you" means the person or organization who evaluates the software, or had purcased a license to use the software, or otherwise uses the software according to the conditions of this license agreement.
1. EVALUATION. You may evaluate the software for 30 days. After this time you must register it (purchase a license) or remove it from the system.

2. LICENSE. Once you registered the software, you are granted a license to use the software, as well as all future versions of the software. You must keep the registration information in secret.

A registered copy of the software may either be used by a single person who uses the software personally on up to 5 computers, or used on a single computer by multiple people nonsimultaneously.

3. SITE LICENSE. A site license entitles to use the software on computers that are property of the organization or its members.

4. COPYRIGHT AND OWNERSHIP. The software is owned and copyrighted by Gintaras Didzgalvis (author). The software is protected by copyright laws. You acknowledge that no title to the intellectual property in the software is transferred to you.

5. DISTRIBUTION. The software may be freely distributed, provided the distribution package is not modified. No person or company may charge a fee for the software (except a distribution fee) without written permission from the author.

6. REVERSE ENGINEERING. You agree that you will not attempt to reverse compile, modify, translate, or disassemble the software. However you are free to modify the open-source parts (extensions and samples).

7. NO OTHER WARRANTIES. Author does not warrant that the software is error-free. Author does not warrant that future versions of the software will be fully compatible with this version. Author disclaims all other warranties with respect to the software.

8. NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall author or its suppliers be liable to you for any consequential, special, incidental or indirect damages of any kind arising out of the delivery, performance or use of the software
#9
What are you trying to work up with QM...

If it'll help make a sale to your company, I'll help. It's the least I can do to pay back for all the help I've gotten so far through this forum...

Jimmy Vig.
#10
The company I work for has decided that they will make it a present to me but I have to wait for about 1 month, some kind of red tape. That means that I will own it but I think that they will own the programs that I make for them (some programs “ha” I am just starting and although I have allot of self learned PC knowledge it will be a wile before I understand qm).


Forum Jump:


Users browsing this thread: 1 Guest(s)