Echo toolbar button names via PHP


#1

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!


#2

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


#3

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!


#4

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?


#5

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.


#6

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).


#7

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.


#8

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


#9

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;

#10

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.


#11

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.


#12

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”);


#13

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?


#14

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;

#15

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:)


#16

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…


#17

Can you publish sqlite path and table content ?

Gilbert


#18

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


#20

Ok, found solution (it was my mistake):

using

exo_runhescriptcom

rather than

exo_return_hescriptcom


#21

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,