How to put an array as a combo box item

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mhcha
Junior Coder
Posts: 31
Joined: Sat Jan 01, 2022 11:10 am

How to put an array as a combo box item

Post by mhcha » Mon Jun 03, 2024 1:18 pm

Hello, if there is an array as below, I would like to put it in the combo box item as many as the number of those arrays.

Code: Select all

0: SHEETARRAY_1_1=No.
0: SHEETARRAY_1_2=Name
0: SHEETARRAY_1_3=Test
0: SHEETARRAY_1_4=
0: SHEETARRAY_1_COUNT=4
0: SHEETARRAY_2_1=A
0: SHEETARRAY_2_2=Name1
0: SHEETARRAY_2_3=Test1
0: SHEETARRAY_2_4=
0: SHEETARRAY_2_COUNT=4
0: SHEETARRAY_3_1=B
0: SHEETARRAY_3_2=Name2
0: SHEETARRAY_3_3=Test2
0: SHEETARRAY_3_4=
0: SHEETARRAY_3_COUNT=4
0: SHEETARRAY_4_1=C
0: SHEETARRAY_4_2=Name3
0: SHEETARRAY_4_3=Test3
0: SHEETARRAY_4_4=
0: SHEETARRAY_4_COUNT=4
0: SHEETARRAY_5_1=D
0: SHEETARRAY_5_2=Name4
0: SHEETARRAY_5_3=Test4
0: SHEETARRAY_5_4=
0: SHEETARRAY_5_COUNT=4
0: SHEETARRAY_6_1=E
0: SHEETARRAY_6_2=Name5
0: SHEETARRAY_6_3=Test5
0: SHEETARRAY_6_4=
0: SHEETARRAY_6_COUNT=4
0: SHEETARRAY_7_1=
0: SHEETARRAY_7_2=
0: SHEETARRAY_7_3=
0: SHEETARRAY_7_4=
0: SHEETARRAY_7_COUNT=4
0: SHEETARRAY_COUNT=7
I'd like to make all the values of SHEETARRAY_%CountArray%_2 a combo box item out of these. Is there a good way?

User avatar
Grovkillen
Automation Wizard
Posts: 1062
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: How to put an array as a combo box item

Post by Grovkillen » Mon Jun 03, 2024 3:26 pm

You want them in one combo box or multiple combo boxes?
Let>ME=%Script%

Running: 15.0.24
version history

mhcha
Junior Coder
Posts: 31
Joined: Sat Jan 01, 2022 11:10 am

Re: How to put an array as a combo box item

Post by mhcha » Tue Jun 04, 2024 12:14 am

Grovkillen wrote:
Mon Jun 03, 2024 3:26 pm
You want them in one combo box or multiple combo boxes?
Thank you for your interest.

I want to put Name1, Name2, Name3, Name4, and Name5 as items in one combo box. (As many as the number of arrays)

User avatar
Grovkillen
Automation Wizard
Posts: 1062
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: How to put an array as a combo box item

Post by Grovkillen » Fri Jun 07, 2024 10:49 am

Here's an example:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 2496
  Top = -1121
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 211
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSComboBox1: tMSComboBox
    Left = 130
    Top = 47
    Width = 145
    Height = 21
    TabOrder = 0
    Text = 'MSComboBox1'
  end
end
EndDialog>Dialog1

//THIS IS WHAT YOU WANT TO DO TO POPULATE A STRING WITH COMBOBOX SYNTAX DATA
Let>ITEM_LIST=
Let>k=0
Repeat>k
  Let>k=k+1
  Let>TEMP_name=SHEETARRAY_%k%_2
  ConCat>ITEM_LIST,%CRLF%%TEMP_name%
Until>k=SHEETARRAY_COUNT
Trim>ITEM_LIST,ITEM_LIST

//Add the data to the combobox
SetDialogProperty>Dialog1,MSComboBox1,ListText,ITEM_LIST

//Set which name/item you want to be pre-selected, 0 is the first one.
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0


Show>Dialog1,r
Let>ME=%Script%

Running: 15.0.24
version history

mhcha
Junior Coder
Posts: 31
Joined: Sat Jan 01, 2022 11:10 am

Re: How to put an array as a combo box item

Post by mhcha » Wed Jun 19, 2024 2:44 am

Grovkillen wrote:
Fri Jun 07, 2024 10:49 am
Here's an example:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 2496
  Top = -1121
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 211
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSComboBox1: tMSComboBox
    Left = 130
    Top = 47
    Width = 145
    Height = 21
    TabOrder = 0
    Text = 'MSComboBox1'
  end
end
EndDialog>Dialog1

//THIS IS WHAT YOU WANT TO DO TO POPULATE A STRING WITH COMBOBOX SYNTAX DATA
Let>ITEM_LIST=
Let>k=0
Repeat>k
  Let>k=k+1
  Let>TEMP_name=SHEETARRAY_%k%_2
  ConCat>ITEM_LIST,%CRLF%%TEMP_name%
Until>k=SHEETARRAY_COUNT
Trim>ITEM_LIST,ITEM_LIST

//Add the data to the combobox
SetDialogProperty>Dialog1,MSComboBox1,ListText,ITEM_LIST

//Set which name/item you want to be pre-selected, 0 is the first one.
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0


Show>Dialog1,r
Thank you!
I'll try it today.

mhcha
Junior Coder
Posts: 31
Joined: Sat Jan 01, 2022 11:10 am

Re: How to put an array as a combo box item

Post by mhcha » Thu Jun 20, 2024 5:03 am

Grovkillen wrote:
Fri Jun 07, 2024 10:49 am
Here's an example:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 2496
  Top = -1121
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 211
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSComboBox1: tMSComboBox
    Left = 130
    Top = 47
    Width = 145
    Height = 21
    TabOrder = 0
    Text = 'MSComboBox1'
  end
end
EndDialog>Dialog1

//THIS IS WHAT YOU WANT TO DO TO POPULATE A STRING WITH COMBOBOX SYNTAX DATA
Let>ITEM_LIST=
Let>k=0
Repeat>k
  Let>k=k+1
  Let>TEMP_name=SHEETARRAY_%k%_2
  ConCat>ITEM_LIST,%CRLF%%TEMP_name%
Until>k=SHEETARRAY_COUNT
Trim>ITEM_LIST,ITEM_LIST

//Add the data to the combobox
SetDialogProperty>Dialog1,MSComboBox1,ListText,ITEM_LIST

//Set which name/item you want to be pre-selected, 0 is the first one.
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0


Show>Dialog1,r
It works perfectly.
Thank you.

User avatar
Grovkillen
Automation Wizard
Posts: 1062
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: How to put an array as a combo box item

Post by Grovkillen » Thu Jun 20, 2024 6:20 am

Glad to have helped
Let>ME=%Script%

Running: 15.0.24
version history

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