viewpoint-particle

Author Topic: Extracting an item from Reportview  (Read 411 times)

jm0000

  • Newbie
  • *
  • Posts: 13
Extracting an item from Reportview
« on: March 12, 2018, 01:13:22 pm »
Hello all,

           I am still learning WinBatch, and am playing with reportview for my next project.  I basically want a user to choose an APP from a list, then I will install that APP.

I am basically trying to do the following in Dialog Editor

;open the file containing the the Apps to choose from
APPtoinstall=Askfiletext("choose app","C:\temp\appstoinstall.lst", @sorted, @single)
message("You want to install",Apptoinstall)

Here is what I have so far
MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=066
MyDialogY=114
MyDialogWidth=664
MyDialogHeight=268
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`197,249,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`431,249,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`179,019,056,088,REPORTVIEW,"Choose APPS to install",Appsvar,"C:\temp\appstoinstall.lst",DEFAULT,30,@csNoHeader,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

;I can't seem to extract the item chosen. I tried several ways. I  basically want to do something like this.

message("You chose","%APPSVAR%")

 



td

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: Extracting an item from Reportview
« Reply #1 on: March 12, 2018, 01:34:53 pm »
Form the Consolidated WIL Help file:

The name of the variable affected by the control.

"The name of a variable that receives an array of user-selected rows from the control on a non-canceling exit from the dialog.  Optionally, the variable can contain an array of values to display in the control. When the variable is used to populate the control, the control will have a column for each column in the array.  The array can optionally contain text for each column heading in the first row of the array. See the style attribute for details. Note that the array variable contents will only be used to populate the control when the 'text' control definition attribute is set to 'DEFAULT'. Supports variant safe arrays."

The control's variable is populated as a WIL array and not text. 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


jm0000

  • Newbie
  • *
  • Posts: 13
Re: Extracting an item from Reportview
« Reply #2 on: March 12, 2018, 03:04:34 pm »
IS there a way to read the contents of the Array, so that I can use what the user chose.  I really don't need to use the reportview. Is it possible to use the itembox?  Can I read items from a file into an itembox? Something like this?

Appstoinstall="C:\temp\appstoinstall.lst"

;; Using a itembox 1

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=066
MyDialogY=114
MyDialogWidth=664
MyDialogHeight=268
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`197,249,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`431,249,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`201,043,054,064,ITEMBOX,"ItemBox_1",APPStoinstall,"Choose an APP TO install",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

message("you chose",[item user chose"]

td

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: Extracting an item from Reportview
« Reply #3 on: March 12, 2018, 05:56:14 pm »
Arrays are an important data structure in WIL so you should learn how to use them.  Please review the topic  Home -> Windows Interface Language Reference -> WIL Language Elements -> Arrays in the Consolidated WIL Help file.  They are easy to use.

You can use an ITEMBOX if you wish.  The help file states, "The name of the variable affected by the control. The variable is assumed to contain a tab delimited list. The list is loaded into the list box in the original order"

For more information vist the topic Home -> Windows Interface Language Reference -> Things to Know -> Dialogs -> Dialog Control Types -> Itembox Control.

"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


jm0000

  • Newbie
  • *
  • Posts: 13
Re: Extracting an item from Reportview
« Reply #4 on: March 13, 2018, 01:52:59 pm »
Funny thing, as I was opening WinBatch today, that  tip of the day, gave me exactly what I was looking for.  I hope this helps someone else.  I'm writing a script to allow users to choose an Application to setup.  Here is the stripped down part that converts a file to a list. The user is then able to choose from the list. Nothing fancy about the list. It looks like this:

Adbobe
Chrome
.
.
Office

myfile="c:\temp\Appstoinstall.lst"    ; This is a file that has names of apps. The users will choose one of these apps
temp=FileGet(myfile)                ; Load it into a variable
APPSTOinstall=StrReplace(temp,@CRLF,@TAB)

:start
NEWPCdialogFormat=`WWWDLGED,6.2`

NEWPCdialogCaption=`Joe's  New PC Install - v 4.0 03/9/2018 -  Written in Winbatch`
NEWPCdialogX=100
NEWPCdialogY=1044
NEWPCdialogWidth=306
NEWPCdialogHeight=288
NEWPCdialogNumControls=004
NEWPCdialogProcedure=`DEFAULT`
NEWPCdialogFont=`DEFAULT`
NEWPCdialogTextColor=`DEFAULT`
NEWPCdialogBackground=`DEFAULT,DEFAULT`
NEWPCdialogConfig=0

NEWPCdialog001=`025,157,036,012,PUSHBUTTON,"PushButton_Run",DEFAULT,"Run",1,5,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
NEWPCdialog002=`137,157,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
NEWPCdialog003=`077,157,036,012,PUSHBUTTON,"PushButton_Help",DEFAULT,"Help",30,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
NEWPCdialog004=`057,039,114,078,ITEMBOX,"ItemBox",APPSTOINSTALL,DEFAULT,DEFAULT,170,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("NEWPCdialog")

message("You chose",APPSTOinstall)

I'll play with Array later.  This does exactly what I wanted.