Variable Number of Controls in a Dialog
Keywords: Variable Number Controls Dialog Dynamically Create
Question:
Can you have a WB script read from a list of names and show a box with a list of names and a check mark box next to each name. Then if I add names to the .txt file it will show the new added name and a check mark box next to it?Answer:
Maybe take a look at the Wil Dialog Editor. Also get really familiar with the Dialog function. You could create a script that dynamically creates a dialog with the number of names from your list...Here is one example:
path=IntControl (1004, 0, 0, 0, 0) pfix=FilePath(path) while 1 names=IniItemizePvt ("names", "%pfix%names.ini") count = ItemCount(names,@tab) MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`SYS PAGER v1.0` MyDialogX=9999 MyDialogY=9999 MyDialogWidth=291 MyDialogHeight=25 MyDialogNumControls=(count)+7 ;Includes two pushbuttons MyDialog01=`120,2,49,DEFAULT,PUSHBUTTON,DEFAULT,"&Send",1` MyDialog02=`176,2,49,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0` MyDialog03=`120,20,105,DEFAULT,STATICTEXT,DEFAULT,"Enter pager message here:"` MyDialog04=`120,30,105,DEFAULT,EDITBOX,msg,""` MyDialog05=`10,5,100,DEFAULT,STATICTEXT,DEFAULT,"Select Recipient(s):"` MyDialog06=`120,45,105,DEFAULT,PUSHBUTTON,DEFAULT,"&Add Recipient",2` MyDialog07=`120,59,105,DEFAULT,PUSHBUTTON,DEFAULT,"&Remove Recipient",3` ;builds dialog controls for each item for xx=1 to count item = ItemExtract(xx,names,@tab) dlgup= ((xx-1))+8 dlgup=strfixleft(dlgup,0,2) vert=(xx*9) + 10 vert1=vert-5 MyDialogHeight=MyDialogHeight+8 MyDialog%dlgup%=`11,%vert1%,50,DEFAULT,CHECKBOX,update%xx%,"%item%",1` next ButtonPushed=Dialog("MyDialog") fn="%pfix%names.ini" for xx=1 to count IF update%xx%==1 username=ItemExtract(xx,names,@tab) userdata=IniReadPvt("names",username,"???",fn) Message("Index=%xx%",strcat("Name=",username,@crlf,"Data=",userdata)) ENDIF next ;****Should only go here when it is finished sending message**** message("All Done","All done Sending") endwhile
Article ID: W15119