create object that activates a command when being opened/clicked on

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

create object that activates a command when being opened/clicked on

Postby tvonbrasch » Fri Jul 08, 2022 6:01 am

Hi,

Is it possible to create an object that activates a command when being opened/clicked on?

We have made some addins and in those addins, the user may type the command:

Code: Select all

addinname ?


and then a PDF documentation for that add-in is opened:

Code: Select all

'open help file
   if @upper(%0)="HELP" or %0="?" then
      setmaxerrs 10
      %runpath=@runpath
      %about="about.pdf"
      %runpath=@addquotes(%runpath+%about)   
      shell(t=3000) {%runpath}
      stop
   endif


It would be really good if one could make an object in EViews that executes the commands above when it is clicked on (in some way). What I am looking for is the possibility to create an object that holds the functionality that when a user clicks on that object, then the commands above are executed and the pdf-file with the documentation is opened. Is this doable?
Thomas

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Fri Jul 08, 2022 8:55 am

A User Object can probably be used for this. Although we're currently working on some issues in 12 and 13 with user objects...
Follow us on Twitter @IHSEViews

MartinsFest
Posts: 27
Joined: Tue Dec 13, 2022 4:41 am

Re: create object that activates a command when being opened/clicked on

Postby MartinsFest » Wed Dec 14, 2022 2:15 am

Could you elaborate on how a User Object would be used to make a "Help"-button/object?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Wed Dec 14, 2022 8:19 am

A user object has programs defined for its views and procs, including the default view. You could have that program use the spawn command to open a pdf
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

Re: create object that activates a command when being opened/clicked on

Postby tvonbrasch » Fri Dec 16, 2022 5:40 am

Hi Gareth,

When looking at the documentation on user objects;

https://www.eviews.com/help/helpintro.html#page/content%2Fuserobjcmd-Userobj.html%23

I cannot find any examples of including spawn processes or making programs for the views and procs of the user object. Could you please provide an example illustrating how to do this, that we can build on? Do you have any other documentation of user objects than what is shown in the link above?
Thomas

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Fri Dec 16, 2022 11:37 am

Follow us on Twitter @IHSEViews

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Fri Dec 16, 2022 11:48 am

I just knocked one up that lets me open up the latest cricket scores from an object in an EViews workfile (why haven't we added this as a built in feature?!)

CricketScore.zip
(1.04 KiB) Downloaded 109 times
Follow us on Twitter @IHSEViews

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: create object that activates a command when being opened/clicked on

Postby startz » Sat Dec 17, 2022 7:55 am

[quote="EViews Gareth"]I just knocked one up that lets me open up the latest cricket scores from an object in an EViews workfile (why haven't we added this as a built in feature?!)

Of what possible use it it to explain crickets to Americans?

MartinsFest
Posts: 27
Joined: Tue Dec 13, 2022 4:41 am

Re: create object that activates a command when being opened/clicked on

Postby MartinsFest » Mon Dec 19, 2022 3:07 am

Thanks, Gareth! Being Norwegian, I of course prefer to view the latest cross-country-results. I have added a relevant attachment - looking forward to see it built in in Eviews 14!

I have a plethora of short follow-up questions, however.

After adding the user object, I would like for it to appear in the object interface. How do I go about doing that?

Next is kind of a "best-practice"-question. At the moment Eviews finds the User objects in a default file path, which would be dandy if it was only I that needed to run this program. Our programs and workfiles are all accessed by a team on a server. Could I set a new default path for the user objects when our programs run, or should we have explicit paths for each object?

In the spawn-command, you specify "explorer". Does this choose the default explorer installed? And is this option only relevant when redirecting to web-pages? Also, if I for some silly reason would like my object to run a Python-script, do I need to specify any other options?

And finally, I have come over the shell-command. Does this perform similarly to spawn? Or is it more of a tool to navigate and edit directories? The documentation I have found on it is pretty sparse.
Attachments
Cross-country.zip
(1.06 KiB) Downloaded 86 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Mon Dec 19, 2022 9:14 am

  • You cannot add it to the object menu
  • Add-ins->Manage User Objects allows you to change the default installation directory. This location is also stored in UserObjReg.ini in the EViews ini file folder.
  • Spawn simply executes any process, including any built-in Windows processes available in your Windows environment. I'm a bit rusty on Windows Commands, but I just happen to know that the explorer process will launch the Windows default web browser if you feed it a url as the argument.
  • I could probably have used Shell instead to do the same thing. Shell has more functionality since it allows you to execute any Windows Command.
Follow us on Twitter @IHSEViews

MartinsFest
Posts: 27
Joined: Tue Dec 13, 2022 4:41 am

Re: create object that activates a command when being opened/clicked on

Postby MartinsFest » Tue Dec 20, 2022 4:55 am

Thank you very much. I am close to making something I can use.

By object interface I mean the window where the workfile's series, equations, etc. are viewed. I am not certain what is meant by "object menu", but that was not the interface I meant to refer to.

Last question, elaborating on last post's first question: whenever the program adds the object to the object interface it automatically opens the url with the cross-country scores. Is there a way to surpress this when generating the object? I only want to view the contents of the url whenever I click on the button (after it has been generated), not when I generate it.

Image

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Tue Dec 20, 2022 7:49 am

Modify the constructor program (to make it do nothing)
Follow us on Twitter @IHSEViews

MartinsFest
Posts: 27
Joined: Tue Dec 13, 2022 4:41 am

Re: create object that activates a command when being opened/clicked on

Postby MartinsFest » Wed Dec 21, 2022 3:30 am

That helped, thank you.

Ì encountered a new problem. I want to make a help-button for several of our addins, but it seems cluttered to make an individual user-object for each addin.

We have a folder with all the documentation-pdfs, therefore the path in the spawn-command (in viewscores.prg) will barely change each time we create a new object. Can I make it so that I can pass elements of a list (list of the addin-names), so I can reuse the same user object?

MartinsFest
Posts: 27
Joined: Tue Dec 13, 2022 4:41 am

Re: create object that activates a command when being opened/clicked on

Postby MartinsFest » Mon Jan 02, 2023 2:27 am

Hello again and a happy new year,

I haven't yet found a way to parse different paths through the same user object to avoid creating a new user object for each time I want to make a help button. Have you found a solution for this?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: create object that activates a command when being opened/clicked on

Postby EViews Gareth » Mon Jan 02, 2023 9:56 am

I'm not sure I understand what you are asking.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 31 guests