Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questioner Program
#1
My wife wants me to create a program that when you are done answering about a hundred questions it will either take you to a webpage or ask you some more questions and then based on the answers to the questions will give you some information. What would be the best way to make this? Cases, ifs or gotos or is there a better way to make the program?
#2
are you going to be doing the questioning by dialog boxes or one big dialog or some other way.
An old blog on QM coding and automation.

The Macro Hook
#3
I think the best way would be a list; questions 1 to 100 with answer to each question A B C or D. and then based on the answers do something. I will use an EXE dialog for all my work. It will probably look like the tests that we took in school but I do not know how to tally or sum up the answers. Example If(1=B and 2=D and 3=A and 4=D) as you can see this program would take way to much programming and err checking. Is there a better way of doing the programming?
#4
Example with web form in dialog.

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

;out
str controls = "3"
str ax3SHD

;HTML table with questions. Will add radio buttons later.
ax3SHD=
;<style>
;table { border: 2px solid #D1D7DC; border-collapse: collapse; margin: 10px; width: 90%; }
;td,th { border: 1px solid #D1D7DC; border-collapse: collapse; padding-left: 4px; }
;</style>
;<form>
;<table>
;<thead><th>Question</th><th>A</th><th>B</th><th>C</th><th>D</th></thead>
;<!--begin-->
;<tr><td>Question 1</td></tr>
;<tr><td>Question 2</td></tr>
;<tr><td>And so on</td></tr>
;</table>
;</form>

;Add radio buttons.
int-- nrows ncols
ncols=4 ;;change if needed
int i j k=find(ax3SHD "<!--begin-->")
for i 1 1000000
,k=find(ax3SHD "</tr>" k); if(k<0) break
,str s1=""
,for(j 0 ncols) s1.formata("<td><input type=''radio'' name=''r%i''</input></td>" i)
,ax3SHD.insert(s1 k)
,k+s1.len+5
nrows=i-1
;out ax3SHD
;ret
if(!ShowDialog("Dialog64" &Dialog64 &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 ActiveX 0x54030000 0x0 0 0 224 112 "SHDocVw.WebBrowser"
;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
,Htm el
,;for each row
,for i 0 nrows
,,;find checked column
,,for j 0 ncols
,,,el=htm("INPUT" "" "" hDlg 0 i*ncols+j)
,,,if(val(el.Attribute("CHECKED"))) break
,,if(j=ncols) j=-1
,,
,,;out checked column
,,if(j>=0) out "%i. %i (%c)" i j 'A'+j
,,else out "%i. %i (all unchecked)" i j
,
,case IDCANCEL
ret 1
#5
WOW; this is fantastic. It will take me a couple of days just to understand it but it works great!

Thank You
#6
Why can I only have eight questions? When I put more questions and run the macro it is blank.
#7
Download QM 2.3.0 beta. Older versions did not work with big HTML.

Another way - save the HTML to a temporary file with .htm extension. Let ax3SHD be file path insteaf of HTML. For example, insert this before ShowDialog:
Code:
Copy      Help
ax3SHD.setfile("$temp$\x1.htm")
ax3SHD="$temp$\x1.htm"
#8
I did both and both work great; I will have to try the new improvements you made.


Forum Jump:


Users browsing this thread: 1 Guest(s)