Font Size as a variable not working?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Font Size as a variable not working?

Post by Phil Pendlebury » Thu Nov 20, 2008 8:36 pm

Hi there,

I am trying to pass font and size as a variable:

In my .ini file I have :-

def_font=Arial
def_fontsize=6

If I read these values to 2 variables for example "deffont" and "deffontsize"

I can then show the values are read by using a message:

msg>%deffont%,%deffontsize%

Result in the message box: Arial,6

All OK so far.

However, when added into the Dialog:

Code: Select all

Font=%deffont%,%deffontsize%
The font just shows as if "Font=" was added, in other words wrong.

I also tried:

Code: Select all

Let>AllFont=%deffont%,%deffontsize%
and then in the dialog

Code: Select all

Font=%AllFont%
and then

Code: Select all

Font=AllFont
Same results for all, it seems to be being ignored.

Can anyone suggest what I am doing wrong or will MS simply not accept font and font size as an argument?

Thanks.
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Nov 20, 2008 10:15 pm

Can anyone suggest what I am doing wrong or will MS simply not accept font and font size as an argument?
I don't think you're doing anything wrong, looks to me like you've found an anomaly. I tried both version 10 and version 11 and both accept the font description in the dialog block as long as the description is not designated by a variable. If you enter an explicit font face and font size then you will be successful.

Code: Select all

Font=Arial,6
If you have version 10 you can circumvent this problem by using the SetDialogObjectFont> function. It sets the font on each individual object in the dialog rather than setting the entire dialog. It also gives you control over color, bold, italic, underline and strikeout. For Example:

Code: Select all

Let>def_font=Arial
Let>def_fontsize=6
SetDialogObjectFont>dialog1,msbutton1,%def_font%,%def_fontsize%,1,123456
Will set the first dialog1 button's text to a bold 6 point green Arial font.

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Thu Nov 20, 2008 11:25 pm

Hi JRL,

Thanks for that.

The problem is my application has about 15 dialogs and hundreds of separate objects. It would be kind of crazy to use that function for every single object.

So it appears that this is a bug of sorts then, or at least a feature missing.

Request: Ability to set font and font size by variable.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Nov 21, 2008 12:19 am

Damn it even this doesn't work:

Code: Select all

Let>fonts=1
// 1 = Small, 2 = Medium, 3 = Large


Inside Dailog:

Code: Select all

IF>fonts=1
  Font=Arial,6
ENDIF
IF>fonts=2
  Font=Arial,10
ENDIF
IF>fonts=3
  Font=Arial,16
ENDIF
The font is just set to the last value every time, it seems to ignore the IF-ENDIF

:(
Phil Pendlebury - Linktree

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

Post by Marcus Tettmar » Fri Nov 21, 2008 6:29 am

You can't put script code or logic inside a dialog block. A dialog block only does one thing - creates the dialog. Any logic or code inside a dialog block will be ignored.

Anyway, regarding issuing a variable for the font info I will look to see if we can improve this for v11.

I think another solution is a mod to SetDialogObjectFont which if the object name is omitted it will set the font for the entire dialog instead.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Nov 21, 2008 8:02 am

Thanks for the reply Marcus.

:-)
Phil Pendlebury - Linktree

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Nov 21, 2008 7:45 pm

mtettmar wrote:Anyway, regarding issuing a variable for the font info I will look to see if we can improve this for v11.

I think another solution is a mod to SetDialogObjectFont which if the object name is omitted it will set the font for the entire dialog instead.
Thanks Marcus for considering this improvement... it sounds like either one would do the trick... and thanks Phil for posting on this issue.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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