Echo toolbar button names via PHP

Is there any way to echo toolbar button names via PHP (like config file)?

Something like <php echo $name; ?>

Any examples would be greatly appreciated (if possible).

Thanks!

Hi,

It depends from which source you want to echo !
For example, is it from a database or a file where the nameā€™s list exist ?

Gilbert

Hi Gilbert.

Using sqlite db file for this app.

From time to time use a config.php to store values but moving mostly to sqlite.

Thanks!

If I understand, you want to change the names of the buttons in the UI through PHP? We have a demo script in the general demo that changes the caption of the button although this is with HEScript, it can be adapted to be run from PHP too. Is it what you are looking for?

1 Like

Yes, you are correct.

I was looking at the ā€œAsk Userā€ HEScript but did not see how it could be adopted to PHP (or echo from sqlite database). Played around with HEScript trying to get working with vars.php in samples folder but never got anywhere.

If you have time for example, sure would appreciate it.

You can change UI buttons with this HEScript code. For instance, the Home button in the ribbon can be accessed with ID ribbon1BHome. ID is name of the component (ribbon1) followed by name of the control (defined in the UI editor).

procedure Procedure1(text: String);
begin
 SetUiProp("ribbon1BHome", "Caption", text);
end;

So add the script above to the UserMain HEScript script of your project (see https://www.exeoutput.com/help/addscript)

Then, it can be run from PHP with:

exo_return_hescriptcom ('UserMain.Procedure1|New Caption', '');

The | indicates that we pass a parameter (here the value for the text parameter of the Procedure1 procedure defined in the UserMain script).

1 Like

Thanks, I had tried that some time back but could never get the value form a config file to echo.

For instance, just tried again:

require './samples/vars.php';
exo_return_hescriptcom ('UserMain.Procedure1|<?php echo $homebutton; ?>', '');

The <?php echo $homebutton; ?> is returned as button name.

Looking for a way to echo a button name from php file or my sqlite database.

It wonā€™t work with that syntax.
Try instead:
exo_return_hescriptcom ("UserMain.Procedure1|$homebutton", '');

I seem to embarrass myself every time. So simple and did not catch that.

Is there a way to do more than one button? I tried:

require './samples/vars.php';
exo_return_hescriptcom ("UserMain.Procedure1|$homebutton", '');
exo_return_hescriptcom ("UserMain.Procedure3|$gobutton", '');

That does not seem right, so tried:

exo_return_hescriptcom ("UserMain.Procedure1|$homebutton", ''),("UserMain.Procedure3|$gobutton", '') ;

and resulted in error.

Thanks for your help.

EDIT: forgot to show my HEScript:

procedure Procedure3(text: String);
begin
 SetUiProp("ribbon1scButton3", "Caption", text);
end;

Seems I have worn my welcome out on this question, lol. Will try one more time with another since last one not answered:

Everything works ok when changing a single button and echoā€™ing from vars.php.

But I really need to pull data from my sqlite database.

When I use exo_return_hescriptcom ("UserMain.Procedure3|$row['supporttext']", ''); error is thrown.

Possible (please) to give me example how you would use an entry from sqlite database?

Thanks.

The problem comes from the fact that we are trying to modify the GUI through PHP. However, this is not recommended because GUI and PHP are in separate threads.

Change the code to this:

  exo_runhescriptcom ("UserMain.Procedure3|$gobutton");
  exo_runhescriptcom ("UserMain.Procedure1|$home");

and it seems to work better.

Thatā€™s an error in PHP syntax. When you use quotes, you can pass string variables. Thatā€™s all.

Try:
$gobutton = $row[ā€˜supporttextā€™];
exo_runhescriptcom (ā€œUserMain.Procedure3|$gobuttonā€);

Ok, think I am clear on usage, appreciate you taking time to walk me through.

When trying this on the general demo, all seems to work fine. But, my software apps do not use a ribbon, only toolbar (or panel?).

My toolbar is ā€œptopā€ and my button is ā€œscButton1ā€. I have tried:

procedure Procedure3(text: String);
begin
 SetUiProp("scButton1", "Caption", text);
end; 

and

procedure Procedure3(text: String);
begin
 SetUiProp("ptopscButton1", "Caption", text);
end; 

Cannot get button text to change?

Forget last question. Totally related to up all night working and should be in bed:) Spaced out and should have used:

procedure Procedure3(text: String);
begin
 SetUiProp("toolbar1scButton1", "Caption", text);
end;

Unfortunately above not pulling data from sqlite, getting ā€œUndefined variable: rowā€. Can echo on same page using <?php echo $row['supporttext'];?> so know database working.

Anyone got some tips, sure appreciate them:)

UPDATE: Had to move above down a few lines so row was definedā€¦ Now working fine.

Time for sleep so I do not embarrass myself anymore:)

Another related question, pleaseā€¦

Is it possible to also link the button to url and have open in users default browser using scripting?

Using this on modal popup and would like to use in scripting if at all possible:

<a href="heexternal://<?php echo $row['supporturl'];?>"><?php echo $row['supporttext'];?></a></p>

Sorry for all the scripting questions, just cannot seem to graspā€¦

Can you publish sqlite path and table content ?

Gilbert

Hi,

Using as folowing:

procedure Procedure1(text: String);
begin
SetUiProp(ā€œToolbar1BHomeā€, ā€œCaptionā€,text);
end;

procedure Procedure2(text: String);
begin
SetUiProp(ā€œToolbar1bprintā€, ā€œCaptionā€,text);
end;

It is only changing the caption button of first line:
Exemple:

exo_return_hescriptcom (ā€œUserMain.Procedure1|homepageā€.ā€˜ā€™);
exo_return_hescriptcom (ā€œUserMain.Procedure2|Printerā€,ā€˜ā€™);

Only home caption button is changing

But when i use it as follow:

exo_return_hescriptcom (ā€œUserMain.Procedure2|Printerā€,ā€˜ā€™);
exo_return_hescriptcom(ā€œUserMain.Procedure1|homepageā€.ā€˜ā€™);

Only print caption button is changing

Gilbert

Ok, found solution (it was my mistake):

using

exo_runhescriptcom

rather than

exo_return_hescriptcom

Now, how is it possible to have it all as a unique hescript ?
I mean more that to have to write a procedure for each button caption, to put everything in only one hescript and use it as follow;

exo_runhescriptcom(procedure | toolbar+button name | caption, " ")

Thank-you,