Callback functions

Using (or providing) components based on the "Win32" framework

Callback functions

Postby Budgie on Mon Jun 09, 2014 9:05 pm

Hi

What is signified by enclosing the event's callback in square brackets? This happens in ⎕SE:

⎕SE.mb.log.open.Event
Select [OpenLog]

Also, where can I find the code for the OpenLog function.
Jane
User avatar
Budgie
 
Posts: 36
Joined: Thu Nov 26, 2009 9:22 am
Location: Beckenham

Re: Callback functions

Postby ray on Tue Jun 10, 2014 2:50 pm

Dyalog call the events in [square brackets] "system operations".
See chapter 2 (Session Configuration) of the User Guide.

Most of the menu items in standard session are executed via "system operations", for example:
[WSClear]
[WSLoad]
[WSCopy]
...
[Off]
..
[Delete]
[Copy]
[Paste]
..
[LineNumbers]
[Configure]
..
[About]
[DyalogWeb]

I have written several tools that use system operations, but I don't think they are available as APL code.

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 221
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Callback functions

Postby Budgie on Tue Jun 10, 2014 10:54 pm

Thanks, Ray, that's helpful.

What I was hoping to do was load the session-log file under program control whenever a different workspace is loaded (or the default one if one named after the workspace doesn't exist), and maybe also save it at regular intervals so that I've got some stuff from my latest session in the log when APL keels over.

Saving at regular intervals may be OK if I can put [SaveLog] in as the callback for a timer, but then I would also want to put other stuff in there, such as not saving if nothing has changed since last time, etc.

I suppose I'll have to think of other ways of loading the log file.
Jane
User avatar
Budgie
 
Posts: 36
Joined: Thu Nov 26, 2009 9:22 am
Location: Beckenham

Re: Callback functions

Postby AndyS|Dyalog on Wed Jun 11, 2014 9:31 am

One other option may be to use
      txt←⎕se.⎕wg'Log'

to save the contents of the session log into a variable, and then make use of that. However, there is no way to assign to the session log.
User avatar
AndyS|Dyalog
 
Posts: 257
Joined: Tue May 12, 2009 6:06 pm

Re: Callback functions

Postby Veli-Matti on Thu Jun 12, 2014 7:54 am

AndyS|Dyalog wrote:However, there is no way to assign to the session log.


Hmmm.. If I recall it right, I had a functioning session log system some 15 years ago, when
the log handling was different to the current one (the log was not saved).

Reading (and saving) used just the same '⎕SE'⎕WG'Log', and writing was implemented
with a straighforward (but working) technique: ⎕PW←⌈/∊⍴¨logtxt ⋄ ⎕←⊃logtxt (⎕ML being 3).
The trickiest part when reading a new log was to try to find the overlapping part of the
current session log.

If anyone likes to have a copy, I could try to search the function from forgotten directories.

-Veli-Matti
Veli-Matti
 
Posts: 93
Joined: Sat Nov 28, 2009 3:12 pm

Re: Callback functions

Postby Budgie on Thu Jun 12, 2014 9:48 am

Every application should have its own session log file, to avoid losing what happened last time something was done in application xxx when you have been enhancing application yyy for the past week or so. My idea was to change the log file on the fly, and read the new logfile in, replacing what was there already. This was to be done after a )LOAD command, by means of something in ⎕LX. However this can't be done, so I need to do something else.

The easiest way to do this is not to load the workspace with )LOAD, but to use a shortcut either to dyalog.exe specifying the log_file=xxx parameter, or to a batch file (xxx.bat or xxx.cmd) which sets the log_file environment variable before running xxx.dyapp, which is my preferred way of doing things as that way everything is scripted.

If I use one of these methods I don't want to add anything to the log file, but every so often I want to know if the log has changed, i.e. something has been done in the session since the last time it was checked. If so, then I want to save the log, to prevent losing things if APL should terminate abnormally, or if, as happened this morning, the computer shuts itself down because the CPU has got too hot.
Jane
User avatar
Budgie
 
Posts: 36
Joined: Thu Nov 26, 2009 9:22 am
Location: Beckenham

Re: Callback functions

Postby Budgie on Thu Jun 12, 2014 10:43 am

Got it!

      :namespace SaveSessionLog

∇ Start TimerInterval
⍝ <TimerInterval> is time in minutes between saves
:If 0=⎕SE.⎕WX
⎕SE.⎕WX←3
:EndIf
:If 0=⎕NC'CheckSave'
HowManyLines←¯10
Previous←HowManyLines↑⎕SE.Log ⍝ Start with these
'CheckSave'⎕WC'Timer'(60000×TimerInterval)('Event' 'Timer' 'CB_CheckSave')
:Else
:If TimerInterval=0
CheckSave.Active←0
:Else
:If CheckSave.Active=0
CheckSave.Active←1
:EndIf
CheckSave.Interval←60000×TimerInterval
:EndIf
:EndIf


∇ z←CB_CheckSave z;log
⍝ Callback function for CheckSave timer
:If Previous≢log←HowManyLines↑⎕SE.Log ⍝ Only save if there is a difference
⎕NQ'⎕se.mb.log.save' 'Select'
Previous←log ⍝ Update this for the next comparison
:EndIf


:endnamespace
Jane
User avatar
Budgie
 
Posts: 36
Joined: Thu Nov 26, 2009 9:22 am
Location: Beckenham


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest