|
Post by Stefan on Jan 15, 2021 10:56:54 GMT -5
George,
Very minor points here...
Macro Documentation: Syntax is shown as Halt( [rc-num,] msg-str [,msg-str] ...) but it actually behaves as Halt( [rc-num,] [msg-str] [,msg-str] ...)
Function:
I think it would be better if the HALT only produced an audible 'ping' when returning with a non-zero [rc-num]
Presently, every macro that finishes with HALT, regardless of success or failure, with or without messages always 'pings'.
|
|
|
Post by George on Jan 15, 2021 12:13:33 GMT -5
Stefan: Halt already doesn't beep if the RC=0, only on RC>0. Just re-tested it, seems fine.
I'll correct the doc.
George
|
|
|
Post by Stefan on Jan 15, 2021 12:16:11 GMT -5
RobertLOL... I tried the 'visual beep' setting and it drove me potty. Along with many other folks, I'm used to commands, etc issuing a warning 'pling' when they finish with a non-zero RC, but they are usually silent when RC=0. SPFLite does tend follow that convention, e.g. type NONSENSE as a command and the "unknown command" message is accompanied by a 'pling', whereas successful completion is not. I know I could turn the Sound off but that doesn't work well when I wish to listen to music while working. It's only the HALT macro statement that goes against convention.
|
|
|
Post by Stefan on Jan 15, 2021 12:24:52 GMT -5
Stefan: Halt already doesn't beep if the RC=0, only on RC>0. Just re-tested it, seems fine.
Interesting. Mine used to work like that, but hasn't done since version 2 started. In my experience every one of the stmts below causes a 'pling':
HALT HALT(0) HALT(0,Get_Msg$) HALT(4) HALT(8)
If it works for you, what am I missing?
|
|
|
Post by George on Jan 15, 2021 12:35:12 GMT -5
Stefan: Tested some more and also looked at the code. I was wrong, it's not RC <> 0.
The Beep only occurs for FAIL (8), OK(0) and WARN(4), do not Beep.
I can't explain what you're experiencing.
Anyone else getting weird results?
George
|
|
|
Post by Stefan on Jan 15, 2021 12:42:16 GMT -5
Robert I'm not saying many people "love" beeps. I meant that most folks associate a 'sound' with a warning or some kind of abnormal conclusion and associate 'no sound' with 'all is well'. So hearing a sound on EVERY conclusion, even successful ones, seems pointless. My point is the HALT stmt *ALWAYS* makes a sound. I contend that if it must make a sound at all, that should only happen when returning RC>0.
|
|
|
Post by Stefan on Jan 15, 2021 12:59:48 GMT -5
George , OK, I have a better handle on this now. Turns out it is just one of my macros that has this issue. The return code (whether specified as a number or a variable like OK, FAIL, etc) doesn't influence the sound directly.
My macro makes internal calls to SPFLITE commands, e.g.
SPF_Cmd("LOCATE " & Get_Arg$(0))
. . .
Halt(OK,Get_Msg$)
I know that the above sequence may have been better if OK were replaced by Get_RC from the SPF_CMD call, but the noise occurs every time. So it looks like the OK by itself has no effect if, in this case, LOCATE decided to make a noise. Could it be that if any previous function generated a noise, HALT will play the sound, even if the supposed 'error' in the called function is irrelevant.
|
|
|
Post by Stefan on Jan 15, 2021 13:03:48 GMT -5
So, we disassembled the keyboard and found the clacker device, some solid-state sound module, on the circuit board, and thankfully it was connected with a removable wire that we could easily unplug. Once we know that could done, every terminal in the company got a "clacker-ectomy". I don't remember who came up with the term, but it made us all laugh. Robert - THANK YOU for that - best laugh I've had this week!
===> Just remembered, they were Telex terminals. Other than the clack, they actually were really nice, good keyboard, clear display, not too bulky and not too expensive. They did the job.
|
|
|
Post by George on Jan 15, 2021 14:06:10 GMT -5
Stefan: Macro shutdown goes as follows:
GetExitCodeThread(gMacThread, Retval) ' TP.CsrRow = 1: TP.CsrCol = 11 ' reset the command line TP.ErrFlag = 0: TP.ErrMsg = "" ' Clear intermediate errors IF gMacroRC > 0 OR gMacroMsg <> "" THEN ' Something to issue? DoErrorSetup(gMacroRC, gMacroMsg) ' Issue the RC and Msg END IF ' CloseHandle gMacThread ' Clear handle gMacroMode = %False ' Turn off Macro mode KbdPopRestore ' Reset popup state TP.AttnDo = (TP.AttnDo OR %Refresh) ' Ask for refresh EXIT DO ' Done
So .. any intermediate RC and Messages (e.g. from LOCATE) are thrown away If the Macro issued an RC>0 or a Macro Message (e.g. from Halt) then THOSE are issued.
Does this explain what you're seeing?
George
|
|
|
Post by Stefan on Jan 16, 2021 9:00:56 GMT -5
George , You are absolute right... HALT works excactly as you describe. The problem is elsewhere...
I've only tested this with SPF_CMD("FIND....") calls, but it may apply to all SPF_CMD(...) calls, although it does not appear to apply to functions like Get_Line$(<invalid_Lptr>).
If such a call returns a FAIL (e.g. string not found), the macro ends with the 'pling' sound effect. Even if all subsequent calls are successful, the macro will end with a sound effect. Actually, it is worse than that.
The sound is played 'every the time a FAIL event occurs' ! So a macro that issues multiple commands, some of which (it usually expects to) fail, will actually 'play' multiple 'plings'.
Given the execution speed, each new sound preempts the previous one, so you hear only one, at the end of the macro.
This code segment proves it. Save it as a macro and invoke it in the same edit session so you can change it, SAVE it and re-test it easily.
00001 ' IT.MACRO 00002 DIM myRc AS NUMBER, count as NUMBER 00003 FOR count = 1 TO 3 00004 Sleep 2000 ' Play with this value to see the preemption effect 00005 myRC = SPF_CMD("FIND 'notthere' 1 10") 00006 NEXT count 00007 HALT(0,"myRC="+myRC)
You will hear 3 distinct 'plings', one for each time the FIND command fails to find the string.
|
|
|
Post by George on Jan 16, 2021 11:24:18 GMT -5
OK, the Beeps are coming from the normal command execution logic.
I've add 1 line to suppress Beeps if issued "while" a macro is executing. The Beep will only occur after macro completion based on the HALT RC.
George
P.S. Can you avoid posting me via notifications for thread updates. It means I get told twice, once via email, and a second when I have to go check the notifications in the forum.
|
|