Naming buttons in Dialog with array info

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Naming buttons in Dialog with array info

Post by mduffin » Wed Jun 03, 2015 8:14 pm

I've loaded XLSheetToArray and the Watch list shows that it's imported "0: ARRAY_10_1=36412"
I'm trying to create a dialog button that can use variables as names.

Every day the macro runs new, it will load the xls sheet to the array (new excel sheet every day)
The excel sheet can have anywhere from 1 to 40 lines.
I'd like to create say 40 buttons and name each one with what is in ARRAY_(1-40)_1

However when I set Caption = 'ARRAY_2_1' or even tried using %%. it just displays what is in the box.
I've also tried removing the quotes", then I just get errors

Is this something that can't be done?
I'm using MS 14.1

Thanks in advance
Mark

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Naming buttons in Dialog with array info

Post by Marcus Tettmar » Thu Jun 04, 2015 11:03 am

Hi,

Object names are static and set in stone. They are not something the user sees. So, no, you can't do that I'm afraid.

The Caption is what the user sees.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Naming buttons in Dialog with array info

Post by hagchr » Thu Jun 04, 2015 11:51 am

Wouldn't it be possible to change the object names if you put the dialog code into a label and then use LabeltoVar> to get it into a variable, then do the adjustments (buttons, names, captions etc) through some string work and finally use IncludefromVar> and Show> to get the modified dialog? (ie change object names before they get static)?

mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Re: Naming buttons in Dialog with array info

Post by mduffin » Thu Jun 04, 2015 12:01 pm

The caption is what I'm attempting to change with variables. Is that also set in stone?

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Naming buttons in Dialog with array info

Post by hagchr » Thu Jun 04, 2015 12:20 pm

Caption is just a parameter so very easy to change (eg use SetDialogProperty>)

For the buttons, one way could be to generate the buttons dynamically based on the Excel file, another way (easier) could be to create the 40 buttons in your dialog (with proper placement etc) and then you read the excel file, modify the captions and hide/disable the un-used buttons.

I guess you also want something to happen when you push buttons so you will need something to handle that as well.

mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Re: Naming buttons in Dialog with array info

Post by mduffin » Thu Jun 04, 2015 1:44 pm

Am I missing something?
The button is blank with this code.
I've tried not using %

The Array is loading as 0: ARRAY_2_1=36512 shows up in the watch list
So 36512 should be in the caption box


Code: Select all

  object WOButton1: tMSButton
    Left = 61
    Top = 61
    Width = 75
    Height = 25
    Caption = ''
    TabOrder = 0
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

Show>Dialog1,
SetDialogProperty>Dialog1,WOButton1,Caption,%ARRAY_2_1%


hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Naming buttons in Dialog with array info

Post by hagchr » Thu Jun 04, 2015 2:12 pm

In this case SetDialogProperty> needs to come before ShowDialog>. (The comma in Show>Dialog1, will make the dialog modal and execution will halt until the dialog is closed, ie it will not reach the SetDialogProperty until it is too late in your example).

mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Re: Naming buttons in Dialog with array info

Post by mduffin » Thu Jun 04, 2015 2:20 pm

OMG I love you!!!

Thank you!

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