Programmatically fire button click event - events

Is there a way to fire a button click event programmatically in Clarion? I've tried the following but they haven't worked:
! Doesn't work:
?ResetInput
! Also doesn't work:
?ResetInput:Accepted

I figured out a solution after a few hours of searching:
POST(EVENT:Accepted, ?ResetInput)
Please post any other answer if there's a more correct way of doing this.
Here's the info regarding the POST function from the Clarion help docs:
POST( event [,control] [,thread] [,position] )
event: An integer constant, variable, expression, or EQUATE containing an event number. A value in the range 400h to 0FFFh is a User-defined event.
control: An integer constant, EQUATE, variable, or expression containing the field number of the control affected by the event. If omitted, the event is field-independent.
thread: An integer constant, EQUATE, variable, or expression containing the execution thread number whose ACCEPT loop is to process the event. If omitted, the event is posted to the current thread.
position: An integer constant, EQUATE, variable, or expression containing either zero (0) or one (1). If one (1), the event message is placed at the front of the event message queue. If omitted or zero (0), the event message is placed at the end of the event message queue.
POST posts an event to the currently active ACCEPT loop of the specified thread. This may be a User-defined event, or any other event. User-defined event numbers can be defined as any integer between 400h and 0FFFh. Any event posted with a control specified is a field-specific event, while those without are field-independent events.
POSTing an event causes the ACCEPT loop to fire but does not cause the event to "happen." For example, POST(EVENT:Selected,?MyControl) executes any code in EVENT:Selected for ?MyControl but does not cause ?MyControl to gain focus.
Example:
Win1 WINDOW('Tools'),AT(156,46,32,28),TOOLBOX
BUTTON('Date'),AT(0,0,,),USE(?Button1)
BUTTON('Time'),AT(0,14,,),USE(?Button2)
END
CODE
OPEN(Win1)
ACCEPT
! Detect user-defined event:
IF EVENT() = EVENT:User THEN BREAK END
CASE ACCEPTED()
OF ?Button1
POST(EVENT:User,,UseToolsThread) !Post field-independent event to other thread
OF ?Button2
POST(EVENT:User) ! Post field-independent event to this thread
END
END
CLOSE(Win1)

Related

How to trigger the event in AnyLogic and then make it cyclic?

I would like to make the cyclic event. This event periodically calculates some parameters of the model. However, the event should be triggered once by a condition. I have no idea how to do that.
I tried to make the event.reset() at the beginning and then restart it after the appropriate condition is met.
However, I received the errors:" agent cannot be resolved to a variable"
If I delete the reset and restart functions for the event, everything will be ok. The event is cyclic and works fine.
The double click on the error shows the stings where the error is occurred (highlighted with red color):
On model start-up, suspend the event by using:
event.reset();
Once the condition you have is met, use:
event.restart();

RxJs Window : not getting last observable

I've written this piece of code,
timer(0, 100)
.pipe(
windowTime(1000),
take(3),
flatMap( value => value.pipe(toArray())))
I don't understand why in my subscribe I only get 2 values. Whatever n take I always get n-1 values in my subscribe.
Could you explain to me why ?
Edit: I suspect a bug therefore I opened a bug.
Interesting problem!
So, windowTime(1000) will emit a new window every 1000ms. But what exactly is a window? A window is Subject instance.
windowTime can manage multiple windows, but when you're only providing its first argument(called windowTimeSpan), there will be only one active window. What this means is that after windowTimeSpan ms pass, the current window will be closed and a new one will be created and pushed into the stream.
When a window is closed, it means that it will send a complete notification. This is a very important aspect.
When you subscribe, a window is going to be created immediately and pushed into the stream.
By doing flatMap(value => value.pipe(toArray()))), you can register observers for the current window(subject). It's semantically the same as subject.pipe(toArray()).subscribe(subscriber)
Why does it behave this way?
timer(0, 100)
.pipe(
// Emit a value(window) every 1000ms and close(complete) the prev one
windowTime(1000),
take(3),
flatMap( value => value.pipe(toArray()))
)
Firstly, let's have a look at flatMap. flatMap is the same as mergeMap. What mergeMap does is to manage a number(concurrent, defaults to INFINITY) of inner observables. An inner observable is being tracked until it completes.
What toArray does it to accumulate values until its source completes. In this case, until the current subject(window) completes. This happens when a window is closed, more specifically, when 1000ms pass.
So, as delineated before, a window will be created immediately on subscription.
After 0ms a value(0) comes in, after 100ms another value(1) and so forth until value 9 comes in. In the meanwhile all these values were collected by toArray. So 9's arrival also marks 1000ms, that is also when the current window will be closed(will emit a complete notification). When this happens, toArray will receive the notification and will send the collected values to the data consumer.
After this a new window is created(second value for take(3)). Then, value 10 comes in, then value 11 and so forth until 19, which marks another 1000ms, which will cause the current window to complete and a new one to be created. But this new window would represent the 3rd value for take(3). This means that take will unsubscribe from its source and will emit a complete notification.
As a result, the source will not be able to receive any other values, so this should explain why you're only getting 2 arrays.

What is pbm_commnotify event in PowerBuilder?

What is pbm_commnotify event in PowerBuilder? How can it be triggered?
global type some_type from Window
...
event commnotify pbm_commnotify
...
end type
on commnotify;
...
end on;
I am working for a project that requires us to convert a system written in Powerbuilder many years ago into a web application. I am new to Powerbuilder and really have no idea how this type of event can be triggered.
Most pbm_xxx event IDs in PowerScript map to wm_Xxx in Win16/Win32.
Your example:
Code for event commnotify is the "event handler" for Win32 message WM_CommNotify.
Be aware:
Some PowerScript event IDs don't map to Win16/Win32 messages.
You may encounter unmapped PowerScript events (events without event IDs).
pbm_custom01, pbm_custom02, ... map to WM_User, (WM_User + 1), ...*

Is the OVERLAPPED::hEvent set even if pipe connection is immediate with ERROR_PIPE_CONNECTED?

If, after an asynchronous ConnectNamedPipe(), one gets ERROR_PIPE_CONNECTED from GetLastError(), will the event in the OVERLAPPED structure passed to the function still be set, or does it only get set if the result was ERROR_IO_PENDING?
A secondary question is, if the completion notification mode is set to FILE_SKIP_SET_EVENT_ON_HANDLE, documentation specifies that the handle's event won't be set, but that the OVERLAPPED structure's event will still be set, if existing. My question is, what is the use of the handle event, and why is that setting not default?
From this example if GetLastError() returned ERROR_PIPE_CONNECTED then you have to set the event yourself.

Subsequent events not triggering in while loop

I have a MAIN VI and a SUB VI which communicate events through control refnum. flow of events is as follows.
1) sub vi changes a value of its control and this event is handled in the main vi(this works).
2) main vi in response to the event changes one of its control and triggers an event from the event handler itself which is handled in the subvi event handler.(this also works).
The first phase is over. Now the main vi is running a while loop and the sub vi is running a while loop and main vi triggers an event every ~150ms. Which is to be handled in the subvi. This is the part which is not happening. I can see the main vi's control getting updated but the event(if generated) is not handled by the subvi. I'm using control's property node->Value(signalling) to change the value as well as trigger the event. What can be the possible cause?
note: the control (whose value is changed), event handler are the same as in the first phase.
Hope my question is clear.
i found the problem .
the subsequent events were not being handled because the loop in which the event handler ran looped once
i.e the initial condition was itself false so the loop only ran once.
this loop was controlled by stop if true. it had to be continue if true.
the boolean variable that controlled this loop was true. this should have been my first clue.

Resources