ListBox dialog control

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

ListBox dialog control

Post by drunkenmonkey » Sun Feb 28, 2021 6:30 pm

Hi! I'm new to this, could you help please.
I want to populate a list from user input. Let say I want the user to enter 5 items in the list so the
will display the items entered by the user in the 5 input. I have this code but it will just show the last
item. Thanks for your help.

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

Dialog>Dialog1
object Dialog1: TForm
  Left = 843
  Top = 157
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 453
  ClientWidth = 594
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -17
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 144
  TextHeight = 20
  object MSListBox1: tMSListBox
    Left = 169
    Top = 86
    Width = 232
    Height = 187
    ItemHeight = 20
    TabOrder = 8
    SelectedIndex = -1
  end
end
EndDialog>Dialog1
//If the Dialog is closed quit the script
AddDialogHandler>Dialog1,,Onclose,Quit

//Set the list text
Let>x=0
While>x<5
Let>x=x+1
Let>INPUT_BROWSE=0
Input>item,Entrer votre item ...
Let>item_Liste=%item%%CRLF%
SetDialogProperty>Dialog1,MSListBox1,Text,%item_Liste%
EndWhile
//Let>item_List=%item%%CRLF%
//Let>item_List=%liste%
//SetDialogProperty>Dialog1,MSListBox1,Text,item_List


//Subroutine to end script
SRT>Quit
  Exit>0
END>Quit
//Display the dialog
Show>dialog1,res1

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ListBox dialog control

Post by Dorian (MJT support) » Sun Feb 28, 2021 10:09 pm

Try this instead. On each loop you were simply replacing %item%

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dialog>Dialog1
object Dialog1: TForm
  Left = 843
  Top = 157
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 453
  ClientWidth = 594
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -17
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 144
  TextHeight = 20
  object MSListBox1: tMSListBox
    Left = 169
    Top = 86
    Width = 232
    Height = 187
    ItemHeight = 20
    TabOrder = 8
    SelectedIndex = -1
  end
end
EndDialog>Dialog1
//If the Dialog is closed quit the script
AddDialogHandler>Dialog1,,Onclose,Quit
//Set the list text
Let>item_Liste=
Let>x=0
While>x<5
Let>x=x+1
Let>INPUT_BROWSE=0
Input>item,Entrer votre item ...
Let>item_Liste=%item_Liste%%item%%CRLF%
SetDialogProperty>Dialog1,MSListBox1,Text,%item_Liste%
EndWhile
//Let>item_List=%item%%CRLF%
//Let>item_List=%liste%
//SetDialogProperty>Dialog1,MSListBox1,Text,item_List
//Subroutine to end script
SRT>Quit
  Exit>0
END>Quit
//Display the dialog
Show>dialog1,res1
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Sun Feb 28, 2021 10:32 pm

Thank you so much Dorian. Again you just made my day. :D :D :D
Have a great day!

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Mon Mar 01, 2021 2:16 pm

Thank you again for your help it is very appreciated. Following the code provided previously,
If I want to add a loop so the result as show in image will change from
Scénario 1 : Homme 30 ....50000
Scénario 2 : Homme 40 ....100000
Scénario 3 : Homme 50 ...250000
To:
Scénario 1 : Homme 30 ....50000
Scénario 2 : Homme 30 ....100000
Scénario 3 : Homme 30 ....250000
Scénario 4 : Homme 30 ....50000
Scénario 5 : Homme 40 ....100000
Scénario 6 : Homme 50 ....250000

A link for the image.
https://u.pcloud.link/publink/show?code ... bnYfYAYtbX

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Mon Mar 01, 2021 2:19 pm

Smal mistake.
result should be
To:
Scénario 1 : Homme 30 ....50000
Scénario 2 : Homme 30 ....100000
Scénario 3 : Homme 30 ....250000
Scénario 4 : Homme 40 ....50000
Scénario 5 : Homme 40 ....100000
Scénario 6 : Homme 40 ....250000
...

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ListBox dialog control

Post by Dorian (MJT support) » Mon Mar 01, 2021 3:06 pm

I'm not sure I follow. Could you explain more please?

Do you want it to start off with this..

Scénario 1 : Homme 30 ....50000
Scénario 2 : Homme 40 ....100000
Scénario 3 : Homme 50 ...250000

..and then change to this?

Scénario 1 : Homme 30 ....50000
Scénario 2 : Homme 30 ....100000
Scénario 3 : Homme 30 ....250000
Scénario 4 : Homme 40 ....50000
Scénario 5 : Homme 40 ....100000
Scénario 6 : Homme 40 ....250000

Or you you simply want it to be the second list to start with?

Or am I totally misunderstanding? :)
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Mon Mar 01, 2021 3:41 pm

Hi Dorian, thank you to reply.

Let say you have a product for:
Client (Male or Female from user selection) - Age (Multiple selection) - SmokinStatus - Amount (Multiple selection)
I want to show for in list
Scenario(x) Client Age(x) SmokingStatus Amount(x)
In the exemple the selection is 3 X Amount and Age X 7 = 21 scenarios

Scénario 1....Homme...30....50000
Scénario 2....Homme...30....100000
Scénario 3....Homme...30....250000
Scénario 4....Homme...40....50000
Scénario 5....Homme...40....100000
Scénario 6....Homme...40....250000
Scénario 7....Homme...50....50000
Scénario 8....Homme...50....100000
Scénario 9....Homme...50....250000
...
...
Scénario 19....Homme...90....50000
Scénario 20....Homme...90....100000
Scénario 21....Homme...90....250000

Here's the code:

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
//List of values to display in Combo Box separated by carriage return / line feed
Let>CBList_prod_par=Vie entière payable 10 ans - Patrimoine bonifié%crlf%Vie entière payable 10 ans - Croissance accélérée%crlf%Vie entière payable 20 ans - Patrimoine bonifié%crlf%Vie entière payable 20 ans - Croissance accélérée%crlf%Vie entière payable à 100 ans - Patrimoine bonifié%crlf%Vie entière payable à 100 ans - Croissance accélérée%crlf%

Let>LW10_nom=Vie entière garantie payable 10 ans
Let>LW15_nom=Vie entière garantie payable 15 ans
Let>LW20_nom=Vie entière garantie payable 20 ans
Let>LW65_nom=Vie entière garantie payable à 65 ans
Let>LW00_nom=Vie entière garantie payable à 100 ans
Let>LT00_nom=Temporaire à 100 ans
Let>LT10_nom=Temporaire 10 ans
Let>LT20_nom=Temporaire 20 ans
Let>LT30_nom=Temporaire 30 ans
Let>LT65_nom=Temporaire 65 ans
Let>MGT10_nom=Priorité santé - temporaire 10 ans
Let>MGT20_nom=Priorité santé - temporaire 20 ans
Let>MGT65_nom=Priorité santé - temporaire 65 ans
Let>MGT75_nom=Priorité santé - temporaire 75 ans
Let>MGT110_nom=Priorité santé - payable 10 ans
Let>MGT120_nom=Priorité santé - payable 20 ans
Let>MGTE_nom=Priorité santé - enfant, payable 20 ans
Let>MGT100_nom=Priorité santé - payable à 100 ans
Let>CPPT75_nom=Priorité santé - affaires, temporaire à 75 ans
Let>CPPT100_nom=Priorité santé - affaires, temporaire à 100 ans
Let>CBList_prod_vie_mg=%LW10_nom%%crlf%%LW15_nom%%crlf%%LW20_nom%%crlf%%LW65_nom%%crlf%%LW00_nom%%crlf%%LT00_nom%%crlf%%LT10_nom%%crlf%%LT20_nom%%crlf%%LT30_nom%%crlf%%LT65_nom%%crlf%%MGT10_nom%%crlf%%MGT20_nom%%crlf%%MGT20_nom%%crlf%%MGT65_nom%%crlf%%MGT75_nom%%crlf%%MGT110_nom%%crlf%%MGT120_nom%%crlf%%MGTE_nom%%crlf%%MGT100_nom%%crlf%%CPPT75_nom%%crlf%%CPPT100_nom%%crlf%

Let>CBList_sex=Homme%crlf%Femme%crlf%
Let>CBList_taux=Privilégié / Non-fumeur%crlf%Régulier / Fumeur%crlf%
Let>CBList_plateforme=Assurance vie / Maladies graves%crlf%Assurance vie avec participation%crlf%Assurance vie universelle%crlf%Assurance invalidité%crlf%
Let>CBList_cie=Desjardins%crlf%Canada Vie%crlf%Empire%crlf%Equitable%crlf%IA%crlf%Manuvie%crlf%RBC%crlf%SunLife%crlf%

//Combo Box property "Text" is set to
//the initial Combo Box display text
Dialog>Dialog1
object Dialog1: TForm
  Left = 843
  Top = 157
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Hypoth'#232'ses des sc'#233'narios'
  ClientHeight = 492
  ClientWidth = 861
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -17
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poMainFormCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 144
  TextHeight = 20
  object lbl_prest_1: TLabel
    Left = 400
    Top = 40
    Width = 85
    Height = 20
    Caption = 'Prestation 1'
  end
  object lbl_prest_2: TLabel
    Left = 400
    Top = 80
    Width = 85
    Height = 20
    Caption = 'Prestation 2'
  end
  object lbl_prest_3: TLabel
    Left = 400
    Top = 120
    Width = 85
    Height = 20
    Caption = 'Prestation 3'
  end
  object lbl_prest_4: TLabel
    Left = 400
    Top = 160
    Width = 85
    Height = 20
    Caption = 'Prestation 4'
  end
  object lbl_prest_5: TLabel
    Left = 400
    Top = 200
    Width = 85
    Height = 20
    Caption = 'Prestation 5'
  end
  object lbl_prest_6: TLabel
    Left = 400
    Top = 240
    Width = 85
    Height = 20
    Caption = 'Prestation 6'
  end
  object lbl_prest_7: TLabel
    Left = 400
    Top = 280
    Width = 85
    Height = 20
    Caption = 'Prestation 7'
  end
  object lbl_prest_8: TLabel
    Left = 400
    Top = 320
    Width = 85
    Height = 20
    Caption = 'Prestation 8'
  end
  object lbl_prest_9: TLabel
    Left = 400
    Top = 352
    Width = 85
    Height = 20
    Caption = 'Prestation 9'
  end
  object lbl_prest_10: TLabel
    Left = 400
    Top = 392
    Width = 94
    Height = 20
    Caption = 'Prestation 10'
  end
  object Label1: TLabel
    Left = 632
    Top = 40
    Width = 42
    Height = 20
    Caption = 'Age 1'
  end
  object Label2: TLabel
    Left = 632
    Top = 80
    Width = 42
    Height = 20
    Caption = 'Age 2'
  end
  object Label3: TLabel
    Left = 632
    Top = 120
    Width = 42
    Height = 20
    Caption = 'Age 3'
  end
  object Label4: TLabel
    Left = 632
    Top = 160
    Width = 42
    Height = 20
    Caption = 'Age 4'
  end
  object Label5: TLabel
    Left = 632
    Top = 200
    Width = 42
    Height = 20
    Caption = 'Age 5'
  end
  object Label6: TLabel
    Left = 632
    Top = 240
    Width = 42
    Height = 20
    Caption = 'Age 6'
  end
  object Label7: TLabel
    Left = 632
    Top = 280
    Width = 42
    Height = 20
    Caption = 'Age 7'
  end
  object Label8: TLabel
    Left = 632
    Top = 320
    Width = 42
    Height = 20
    Caption = 'Age 8'
  end
  object Label9: TLabel
    Left = 632
    Top = 352
    Width = 42
    Height = 20
    Caption = 'Age 9'
  end
  object Label10: TLabel
    Left = 632
    Top = 392
    Width = 51
    Height = 20
    Caption = 'Age 10'
  end
  object MSComboBox1: tMSComboBox
    Left = 15
    Top = 74
    Width = 370
    Height = 28
    Margins.Left = 5
    Margins.Top = 5
    Margins.Right = 5
    Margins.Bottom = 5
    TabOrder = 1
    Text = 'Choisir le produit vie / mg'
  end
  object MSButton1: tMSButton
    Left = 398
    Top = 432
    Width = 115
    Height = 38
    Margins.Left = 5
    Margins.Top = 5
    Margins.Right = 5
    Margins.Bottom = 5
    Caption = 'Ok'
    TabOrder = 27
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object edt_prest_1: TEdit
    Left = 502
    Top = 35
    Width = 121
    Height = 28
    TabOrder = 5
  end
  object edt_prest_2: TEdit
    Left = 502
    Top = 74
    Width = 121
    Height = 28
    TabOrder = 6
  end
  object edt_prest_3: TEdit
    Left = 502
    Top = 116
    Width = 121
    Height = 28
    TabOrder = 7
  end
  object edt_prest_4: TEdit
    Left = 502
    Top = 155
    Width = 121
    Height = 28
    TabOrder = 8
  end
  object edt_prest_5: TEdit
    Left = 502
    Top = 194
    Width = 121
    Height = 28
    TabOrder = 9
  end
  object edt_prest_6: TEdit
    Left = 502
    Top = 237
    Width = 121
    Height = 28
    TabOrder = 10
  end
  object edt_prest_7: TEdit
    Left = 502
    Top = 278
    Width = 121
    Height = 28
    TabOrder = 11
  end
  object edt_prest_8: TEdit
    Left = 502
    Top = 315
    Width = 121
    Height = 28
    TabOrder = 12
  end
  object edt_prest_9: TEdit
    Left = 502
    Top = 350
    Width = 121
    Height = 28
    TabOrder = 13
  end
  object edt_prest_10: TEdit
    Left = 502
    Top = 387
    Width = 121
    Height = 28
    TabOrder = 14
  end
  object MSComboBox3: tMSComboBox
    Left = 16
    Top = 156
    Width = 369
    Height = 28
    TabOrder = 3
    Text = 'Choisir le taux'
  end
  object MSComboBox4: tMSComboBox
    Left = 14
    Top = 37
    Width = 371
    Height = 28
    TabOrder = 0
    Text = 'Choisir la plateforme'
  end
  object MSComboBox5: tMSComboBox
    Left = 10
    Top = 195
    Width = 375
    Height = 28
    TabOrder = 4
    Text = 'Choisir la compagnie'
  end
  object MSListBox1: tMSListBox
    Left = 9
    Top = 240
    Width = 376
    Height = 233
    ItemHeight = 20
    TabOrder = 15
    SelectedIndex = -1
  end
  object edtAge1: TEdit
    Left = 690
    Top = 34
    Width = 50
    Height = 28
    TabOrder = 15
  end
  object edtAge2: TEdit
    Left = 690
    Top = 73
    Width = 50
    Height = 28
    TabOrder = 16
  end
  object edtAge3: TEdit
    Left = 690
    Top = 117
    Width = 50
    Height = 28
    TabOrder = 17
  end
  object edtAge4: TEdit
    Left = 690
    Top = 155
    Width = 50
    Height = 28
    TabOrder = 18
  end
  object edtAge5: TEdit
    Left = 690
    Top = 194
    Width = 50
    Height = 28
    TabOrder = 19
  end
  object edtAge6: TEdit
    Left = 690
    Top = 237
    Width = 50
    Height = 28
    TabOrder = 20
  end
  object edtAge7: TEdit
    Left = 690
    Top = 279
    Width = 50
    Height = 28
    TabOrder = 21
  end
  object edtAge8: TEdit
    Left = 690
    Top = 315
    Width = 50
    Height = 28
    TabOrder = 22
  end
  object edtAge9: TEdit
    Left = 690
    Top = 350
    Width = 50
    Height = 28
    TabOrder = 23
  end
  object edtAge10: TEdit
    Left = 690
    Top = 387
    Width = 50
    Height = 28
    TabOrder = 24
  end
  object chkSexMale: TCheckBox
    Left = 755
    Top = 34
    Width = 97
    Height = 26
    Caption = 'Homme'
    TabOrder = 25
  end
  object chkSexFemme: TCheckBox
    Left = 755
    Top = 73
    Width = 97
    Height = 28
    Caption = 'Femme'
    TabOrder = 26
  end
  object MSComboBox2: tMSComboBox
    Left = 16
    Top = 113
    Width = 369
    Height = 28
    TabOrder = 2
    Text = 'Choisir le produit vie par'
  end
end
EndDialog>Dialog1
//If the Dialog is closed quit the script
AddDialogHandler>Dialog1,,Onclose,Quit


//If the "Ok" button is picked, procees the combo box selection
AddDialogHandler>Dialog1,msButton1,Onclick,Process
//Set the combo box list text

SetDialogProperty>Dialog1,MSComboBox2,listtext,CBlist_prod_par
SetDialogProperty>Dialog1,mscombobox1,listtext,CBList_prod_vie_mg

SetDialogProperty>Dialog1,mscombobox3,listtext,CBlist_taux
SetDialogProperty>Dialog1,mscombobox4,listtext,CBlist_plateforme
SetDialogProperty>Dialog1,mscombobox5,listtext,CBlist_cie


//Subroutine to end script
SRT>Quit
  Exit>0
END>Quit
//Display the dialog
Show>dialog1,res1

//Subroutine to Process combo box selection
SRT>Process
  //GetDialogProperty>Dialog1,msComboBox1,text,nom_produit_par
  //GetDialogProperty>Dialog1,msComboBox1,text,nom_produit_vie_mg
  
  GetDialogProperty>Dialog1,chkSexMale,Checked,chkMale
  GetDialogProperty>Dialog1,chkSexFemme,Checked,chkFemale
  
  GetDialogProperty>Dialog1,edtAge1,text,code_age1
  GetDialogProperty>Dialog1,edtAge2,text,code_age2
  GetDialogProperty>Dialog1,edtAge3,text,code_age3
  GetDialogProperty>Dialog1,edtAge4,text,code_age4
  GetDialogProperty>Dialog1,edtAge5,text,code_age5
  GetDialogProperty>Dialog1,edtAge6,text,code_age6
  GetDialogProperty>Dialog1,edtAge7,text,code_age7
  GetDialogProperty>Dialog1,edtAge8,text,code_age8
  GetDialogProperty>Dialog1,edtAge9,text,code_age9
  GetDialogProperty>Dialog1,edtAge10,text,code_age10
  GetDialogProperty>Dialog1,msComboBox1,text,nom_produit_vie_mg
  GetDialogProperty>Dialog1,msComboBox2,text,nom_produit_par
  GetDialogProperty>Dialog1,msComboBox3,text,nom_taux
  GetDialogProperty>Dialog1,msComboBox4,text,nom_plateforme
  GetDialogProperty>Dialog1,msComboBox5,text,nom_cie
  GetDialogProperty>Dialog1,edt_prest_1,text,nom_prest_1
  GetDialogProperty>Dialog1,edt_prest_2,text,nom_prest_2
  GetDialogProperty>Dialog1,edt_prest_3,text,nom_prest_3
  GetDialogProperty>Dialog1,edt_prest_4,text,nom_prest_4
  GetDialogProperty>Dialog1,edt_prest_5,text,nom_prest_5
  GetDialogProperty>Dialog1,edt_prest_6,text,nom_prest_6
  GetDialogProperty>Dialog1,edt_prest_7,text,nom_prest_7
  GetDialogProperty>Dialog1,edt_prest_8,text,nom_prest_8
  GetDialogProperty>Dialog1,edt_prest_9,text,nom_prest_9
  GetDialogProperty>Dialog1,edt_prest_10,text,nom_prest_10
  GetDialogProperty>Dialog1,MSListBox1,SelectedItems,nom_scenario

If>%nom_scenario%<>
Let>MSG_WIDTH=750
  MDL>%nom_scenario%
endif

  //assigner le code plateforme au choix plateforme
if>nom_plateforme=Assurance vie / Maladies graves
//Gosub>PRODUITS_VIE
Let>code_plateforme=1037400001
MDL>code_plateforme
endif

if>nom_plateforme=Assurance vie avec participation
//Gosub>PRODUITS_PAR
Let>code_plateforme=1037400003
MDL>code_plateforme
endif

if>nom_plateforme=Assurance vie universelle
Let>code_plateforme=1037400002
endif

if>nom_plateforme=Assurance invalidité
Let>code_plateforme=1037400004
endif


//SRT>PRODUITS_PAR
  //assigner le code produit au choix produit par
if>nom_produit_par=Vie entière payable 10 ans - Patrimoine bonifié
Let>code_produit=PE10
endif

if>nom_produit_par=Vie entière payable 10 ans - Croissance accélérée
Let>code_produit=PF10
endif

if>nom_produit_par=Vie entière payable 20 ans - Patrimoine bonifié
Let>code_produit=PE20
endif

if>nom_produit_par=Vie entière payable 20 ans - Croissance accélérée
Let>code_produit=PF20
endif

if>nom_produit_par=Vie entière payable à 100 ans - Patrimoine bonifié
Let>code_produit=PE00
endif

if>nom_produit_par=Vie entière payable à 100 ans - Croissance accélérée
Let>code_produit=PF00
endif
//END>PRODUITS_PAR

//SRT>PRODUITS_VIE
  //assigner le code produit au choix produit vie mg
if>nom_produit_vie_mg=Vie entière garantie payable 10 ans
Let>code_produit=LW10
endif

if>nom_produit_vie_mg=Vie entière garantie payable 15 ans
Let>code_produit=LW15
endif

if>nom_produit_vie_mg=Vie entière garantie payable 20 ans
Let>code_produit=LW20
endif

if>nom_produit_vie_mg=Vie entière garantie payable 65 ans
Let>code_produit=LW65
endif

if>nom_produit_vie_mg=Vie entière garantie payable à 100 ans
Let>code_produit=LW00
endif

if>nom_produit_vie_mg=Temporaire à 100 ans
Let>code_produit=LT00
endif

if>nom_produit_vie_mg=Temporaire 10 ans
Let>code_produit=LT10
endif

if>nom_produit_vie_mg=Temporaire 20 ans
Let>code_produit=LT20
endif

if>nom_produit_vie_mg=Temporaire 30 ans
Let>code_produit=LT30
endif

if>nom_produit_vie_mg=Temporaire 65 ans
Let>code_produit=LT65
endif

if>nom_produit_vie_mg=Priorité santé - temporaire 10 ans
Let>code_produit=MGT10
endif

if>nom_produit_vie_mg=Priorité santé - temporaire 20 ans
Let>code_produit=MGT20
endif

if>nom_produit_vie_mg=Priorité santé - temporaire 65 ans
Let>code_produit=MGT65
endif

if>nom_produit_vie_mg=Priorité santé - temporaire 75 ans
Let>code_produit=MGT75
endif

if>nom_produit_vie_mg=Priorité santé - payable 10 ans
Let>code_produit=MGT110
endif

if>nom_produit_vie_mg=Priorité santé - payable 20 ans
Let>code_produit=MGT120
endif

if>nom_produit_vie_mg=Priorité santé - enfant, payable 20 ans
Let>code_produit=MGTE
endif

if>nom_produit_vie_mg=Priorité santé - payable à 100 ans
Let>code_produit=MGT100
endif

if>nom_produit_vie_mg=Priorité santé - affaires, temporaire à 75 ans
Let>code_produit=CPPT75
endif

if>nom_produit_vie_mg=Priorité santé - affaires, temporaire à 100 ans
Let>code_produit=CPPT100
endif
//END>PRODUITS_VIE

  //assigner le code sexe au choix sexe

If>chkMale=True
Let>code_sexe=Homme
Endif

If>chkSexFemme=True
Let>code_sexe=Femme
Endif

  //assigner le code age
if>code_age1<>
Let>code_age_1=code_age1
Let>nb_scenario_age=1
endif

if>code_age2<>
Let>code_age_2=code_age2
Let>nb_scenario_age=2
endif

if>code_age3<>
Let>code_age_3=code_age3
Let>nb_scenario_age=3
endif

if>code_age4<>
Let>code_age_4=code_age4
Let>nb_scenario_age=4
endif

if>code_age5<>
Let>code_age_5=code_age5
Let>nb_scenario_age=5
endif

if>code_age6<>
Let>code_age_6=code_age6
Let>nb_scenario_age=6
endif

if>code_age7<>
Let>code_age_7=code_age7
Let>nb_scenario_age=7
endif

if>code_age8<>
Let>code_age_8=code_age8
Let>nb_scenario_age=8
endif

if>code_age9<>
Let>code_age_9=code_age9
Let>nb_scenario_age=9
endif

if>code_age10<>
Let>code_age_10=code_age10
Let>nb_scenario_age=10
endif
  
  //assigner le code taux au choix taux

if>nom_taux=Privilégié / Non-fumeur
Let>code_taux=1
endif

if>nom_taux=Régulier / Fumeur
Let>code_taux=2
endif


  //assigner le code cie au choix cie

if>nom_cie=Desjardins
Let>code_cie=1
endif

if>nom_cie=Canada Vie
Let>code_cie=2
endif

if>nom_cie=Empire
Let>code_cie=3
endif

if>nom_cie=Equitable
Let>code_cie=4
endif

if>nom_cie=IA
Let>code_cie=5
endif

if>nom_cie=Manuvie
Let>code_cie=6
endif

if>nom_cie=RBC
Let>code_cie=7
endif

if>nom_cie=SunLife
Let>code_cie=8
endif

/*
  MDL>nom_plateforme
  MDL>code_plateforme

  MDL>nom_produit
  MDL>code_produit

  MDL>code_sexe

  MDL>code_age

  MDL>nom_taux
  MDL>code_taux
*/

  //assigner le code prestation au choix prestation

if>nom_prest_1<>
Let>code_prest_1=nom_prest_1
Let>nb_scenario=1
//MDL>code_prest_1
endif

if>nom_prest_2<>
Let>code_prest_2=nom_prest_2
Let>nb_scenario=2
//MDL>code_prest_2
endif

if>nom_prest_3<>
Let>code_prest_3=nom_prest_3
Let>nb_scenario=3
//MDL>code_prest_3
endif

if>nom_prest_4<>
Let>code_prest_4=nom_prest_4
Let>nb_scenario=4
//MDL>code_prest_4
endif

if>nom_prest_5<>
Let>code_prest_5=nom_prest_5
Let>nb_scenario=5
//MDL>code_prest_5
endif

if>nom_prest_6<>
Let>code_prest_6=nom_prest_6
Let>nb_scenario=6
//MDL>code_prest_6
endif

if>nom_prest_7<>
Let>code_prest_7=nom_prest_7
Let>nb_scenario=7
//MDL>code_prest_7
endif

if>nom_prest_8<>
Let>code_prest_8=nom_prest_8
Let>nb_scenario=8
//MDL>code_prest_8
endif

if>nom_prest_9<>
Let>code_prest_9=nom_prest_9
Let>nb_scenario=9
//MDL>code_prest_9
endif

if>nom_prest_10<>
Let>code_prest_10=nom_prest_10
Let>nb_scenario=10
//MDL>code_prest_10
endif

  //MDL>nom_cie
  //MDL>code_cie

  //MDL>Nombre de scénario : %nb_scenario%
  

  //Set the list text
  Let>item_Liste=
  Let>x=0
  While>x<%nb_scenario%
    Let>x=x+1
    Let>montant=code_prest_%x%
    Let>code_age=code_age_%x%
    Let>item=scénario %x% : %code_sexe% %code_age% %nom_taux% %montant%
    Let>item_Liste=%item_Liste%%item%%CRLF%
    SetDialogProperty>Dialog1,MSListBox1,Text,%item_Liste%
  EndWhile
  
  //CloseDialog>Dialog1
END>Process

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ListBox dialog control

Post by Dorian (MJT support) » Mon Mar 01, 2021 5:31 pm

I'm still trying to understand, maybe we now have too much information. Are you able to describe a simple principle for what you're wishing to do? Can we go back to basics and forget the 700+ line example and work with something simple so we can demonstrate a principle? Apologies if I am being slow.
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Mon Mar 01, 2021 6:09 pm

Hi Dorian! Thank you again for your help.
As you see in the picture there is 2 columns -> Prestation and Age
I want to show all possible scénario from user selection based on those 2 variable
Scenario(Z) = Prestation(x) X Age(Y).

Hope it helps!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 885
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: ListBox dialog control

Post by Dorian (MJT support) » Mon Mar 01, 2021 7:18 pm

Here's something from scratch that I think is the beginning of what you want to do. It should demonstrate a basic principle and allow you to build from there. Build your strings within the PopulateList subroutine, then set the dialog property to display your strings at the end of the subroutine.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 2322
  Top = 431
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 888
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object MSComboBox1: tMSComboBox
    Left = 46
    Top = 43
    Width = 290
    Height = 40
    TabOrder = 0
    Text = 'Category 1'
  end
  object MSComboBox2: tMSComboBox
    Left = 50
    Top = 109
    Width = 290
    Height = 40
    TabOrder = 1
    Text = 'Category 2'
  end
  object MSListBox1: tMSListBox
    Left = 373
    Top = 47
    Width = 242
    Height = 194
    ItemHeight = 32
    TabOrder = 2
    SelectedIndex = -1
  end
  object MSButton1: tMSButton
    Left = 644
    Top = 45
    Width = 150
    Height = 50
    Caption = 'Go!'
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1


Let>List1=Option1%crlf%Option2%crlf%Option3
Let>List2=Option4%crlf%Option5%crlf%Option6

SetDialogProperty>Dialog1,MSComboBox1,listtext,List1
SetDialogProperty>Dialog1,MSComboBox2,listtext,List2
AddDialogHandler>Dialog1,MSButton1,OnClick,PopulateList

SRT>PopulateList
  GetDialogProperty>Dialog1,msComboBox1,text,DD1res
  GetDialogProperty>Dialog1,msComboBox2,text,DD2res
  
  //build your string here
  If>DD1res=Option1
    Let>dd1string=abc
  Endif
  
  If>DD1res=Option2
    Let>dd1string=def
  Endif
  
  If>DD1res=Option3
    Let>dd1string=ghi
  Endif
  
  If>DD2res=Option4
    Let>dd2string=123
  Endif
  
  If>DD2res=Option5
    Let>dd2string=456
  Endif
  
  If>DD2res=Option6
    Let>dd2string=789
  Endif
 
  SetDialogProperty>Dialog1,MSListBox1,Text,%dd1string% %dd2string%
END>PopulateList


show>Dialog1,res



Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Tue Mar 23, 2021 5:56 pm

Hello Dorian,
I have this code that loop a table, but it's not stopping when the element_count is atteign.

Code: Select all

          let>x=0
          
          repeat>x
          let>x=x+1
          ChromeFindElements>session_id,xpath,//table[@id='tableauResultatFixe']/tbody/tr[1]/td[1]/tr,element
          Until>x,element_count
          ChromeGetElementData>session_id,element_1,text,compte
          MDL>%compte%
Column 1 has a index starting at number 1. I want to capture the last row and know what is the value of column 1.

Thank you for your precious help.

mightycpa
Automation Wizard
Posts: 303
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: ListBox dialog control

Post by mightycpa » Tue Mar 23, 2021 11:58 pm

Dorian,

I think I understand, but I had to drink to do it.

DM has a form. 3 fields;
Sex: 2 possible mutually exclusive choices, Homme and Femme. One or the other, not both.
Age: 10(?) possible choices, choose as many as you wish
Smoking Status: 3 possible choices (e.g. Low, Medium, High), choose as many as you wish

In the simplest case, the user might have chosen: Male, Age 30, Low. This form choice will return a single row from his table. He calls that Scenario 1: Homme (male), Age (30), SS (50000, which I've called Low).

If the user had chosen Male, 30, and both low and medium, you'd get the first two rows, where 50K is low and 100K is medium. If the user had chosen Female, 30 and Medium, you would presumably see Femme, 30, 100000 as Scenario 34. But he doesn't show us that scenario. You with me so far?

In DM's example, the user chooses not 1, but several items when he fills it out. He is a man, so in the sex field, he chooses Homme. In the age field, he chooses 7 different selections, 30,40,50,60,70,80,90. In the SS, he chooses all 3 of them, Low, Medium and High. So 1 X 7 X 3 = 21, meaning 21 items in the table will match the choices made.

He likely has a table that represents every possible combination a user could select. Imagine there are 60 rows (2 m/f, 10 age, 3 SS), but he's only shown the 21 rows that apply to the selection made on the form in his example. DM does not tell us all that might possibly be selected. He only tells us what selections are CHOSEN:

Code: Select all

Scénario 1....Homme...30....50000
Scénario 2....Homme...30....100000
Scénario 3....Homme...30....250000

...  you have to imagine what is in the middle, and DM doesn't make that easy or intuitive

Scénario 19....Homme...90....50000
Scénario 20....Homme...90....100000
Scénario 21....Homme...90....250000
What he's trying to describe are the intersection of all these choices that are driven by the 21 possible combinations of sex, age and SS that were chosen. Or said another way, he's showing you what rows are returned from the table based on the user's choices.

I hope I haven't had too much to describe it to you well. I'm sure I have imbibed way too much to demonstrate how to return the 21 values from the table, so maybe you can take it from here. :P
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

drunkenmonkey
Junior Coder
Posts: 39
Joined: Fri Jan 31, 2020 10:52 am

Re: ListBox dialog control

Post by drunkenmonkey » Wed Mar 24, 2021 1:32 pm

Thank you mightycpa for your post. I had it worked nicely.
Have a nice :D day!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts