Getting the system's time zone with Dragon NaturallySpeaking's Advanced Scripting - timezone

I want to display the current date and time with Dragon NaturallySpeaking's Advanced Scripting:
I display the date and the time as follows:
Sub Main
DateToday$ = Format(Now,"yyyy-mm-dd hh:nn:ss")
SendKeys DateToday$
End Sub
It outputs something like "2015-01-19 21:45:07".
How can I write the system's time zone as well?
I use Dragon NaturallySpeaking 12.5 Professional with Windows 7 SP1 x64 Ultimate.

Well, see my answer here: https://stackoverflow.com/a/44507647/5521857
So, have Dragon get it by calling another script (autohotkey does it, and use shellexecute with the 6 at the end so it runs minimized) that copies it to the clipboard, and then have Dragon assign the clipboard to a variable and use it. Remember to add a wait, though to make sure the clipboard is populates.

Related

Lua custom file name

In my company i've a QR reader made by Keyence with which we read codes in our production line.
The images acquired by the sensor are saved on an FTP server, and for business needs, the name of the images must be in the format: yyyymmdd_qrcodecontent.jpg.
On the sensor we already have a script in .lua that saves the images with the naming qrcodecontent.jpg.
I don't know the lua language, and from the documentation I could not find info on how to add date information
Do you have any suggestions or advice?
fmset.lua
function nameformatEvent()
local read_data
read_data = readResult():readData()
return(read_data)
end
Lua provides date and time through its os library.
https://www.lua.org/manual/5.4/manual.html#pdf-os
You can get a formatted date string through os.date.
Search the Keyence scripting manual for date and time. Run a script with print(os). If it prints nil that library is not available. At least it is not listed in the manual while some other standard libraries are.
If Keyence's scripting API does not provide the os library and no other means to get the current date and time you cannot access that information.
I'm not aware that the Keyence readers have a realtime clock on-board, so that information is probably not available on the sensor.
Get in touch with the Keyence support. That's what they're getting payed for.
You can probably use some os functions.
For the date formatting on the filename, you could write a quick function like this:
function GenerateFilename()
return os.date("%d%m%y") .. "_qrcodecontent"
end
You can probably configure a filename somewhere. I don't know what the code for readResult and :readData is, but check the content of those functions.
Just add .jpg/.jpeg to the end if it doesn't generate the file extension (change _qrcodecontent to _qrcodecontent.jpg).

Automator mac "Take Screenshot" issue

I need to automate a screenshot task, so I thought why not use automator? I found the "Take Screenshot" Action and started to play with it. The problem is is that is sets the file name and when the workflow is ran again it overwrites the prior screenshot. I tried selecting this and renaming it but it wont work. Essentially what I want is the normal function of command + shift + 3 where it will date-stamp it or something, anything but overwrite!! Any ideas?
I managed to use screencapture and date to do something similar:
fdate=$(date +"$m$d$Y") #I formatted time as mmddyyyy. You can use other formats, add dashes, etc.
screencapture -iW ~/$fdate.png #outputs file at ~/mmddyyyy.png
or something like that. You could wrap this into a shell workflow, or put it in the popular wrapper for OSX, Platypus. I'd seriously like to know how to do that, since I've never been able to understand Platypus.
I took the answer from #user8259 and made it more like the built-in screen capture that you normally see:
# We'll use the default format for the time-stamp
# This could be improved to be more like the Mac's built-in
# screen-shot with yyyy-mm-dd at hh.mm.ss AM/PM
# you would just have to figure out the date-time formatting
# in this shell script.
theTime=`date`
# create the file name for the screen-shot
theFileName="$HOME/Desktop/Screenshot $theTime.png"
#outputs file on the Desktop with a timestamp
screencapture "${theFileName}"
My version of the code includes a time-stamp in addition to the date-stamp to make it less likely that a screen-shot will overwrite a previous screen shot.
You can add this code to an Automator action called the "Run Shell Script" action instead of using the "Take Screenshot" action.

How to abend job intentionally

Is it possible to abend your job intentionally through COBOL program.
suppose I have an Input file having Header,Detail and Trailer records. I will write a COBOL pgm which reads this file.If no Detail records are found in this file then I want to abend my job by giving some Abend Message and some Abend Code.Is it Possible?
Do you want to ABEND your program or just set a RETURN-CODE?
I suspect setting a RETURN-CODE, writing a message
and then terminating the program via a STOP RUN or GOBACK is all that
you really want to do. Causing an actual ABEND may not be necessary.
In an IBM batch environment, the RETURN-CODE set by your program becomes the
RC for the JCL job step the program was run under. This is typically what you
want to set and test for.
The RETURN-CODE is set by MOVEing a numeric value to it. For example:
DISPLAY 'No Detail Records found in file.'
MOVE 16 TO RETURN-CODE
GOBACK.
You may also issue a program dump from a program run under Language Environment (IBM
Mainframe option) using
the CEE3DMP--Generate dump
utility.
In older IBM Mainframe COBOL programs, you might see calls to the ILBOABN0 routine. This call
abended your program and issued a dump. This routine is now depreciated in favour of the
technique outlined above.
Finally, really old programs might have code in them to generate abends. This can be done in any number of ways, but division by zero was
often a favourite:
DIVIDE SOME-NUMBER BY ZERO GIVING SOME-NUMBER.
Works every time!
Personally, I recommend setting the RETURN-CODE over calling ILBOABN0 or data-exception tehcniques.
Note: The RETURN-CODE special-register is not part of the COBOL-85 standard. It is available as an IBM extention to the language. You may need to resort to a different mechanism if you are working in a non-IBM compatible environment.
see the following link on how to set the return code passed back to a JCL job step as well as force an Abened code.
http://www.tek-tips.com/viewthread.cfm?qid=1058302&page=22
First, you should check what is accepted by your own shop's/site's working standards. Most teams will already have an accepted way to deliberately abend a program for a 'logic' reason. One company I worked at has a very simple program called SYSABND2, which I believe is written in assembler, which is called just to abend the program.
That said, to ABEND (not just set return code), you should call module CEE3ABD (or previous version ILBOABN0, which is now deprecated).
For details, see:
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.4.0/com.ibm.zos.v2r4.ceea300/clcdump.htm
http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zos.r9.ceea400/ceea4150320.htm
One method for doing an abnormal end of run is to output a message to the user terminal or to the operator at a mainframe computer centre and possibly to a printer if necessary, all depending on the type of computer the program is to be run on. In cobol it is possible to use DISPLAY UPON .. and use an identifier for the terminal, operator console, or printer as defined in an entry in the SPECIAL-NAMES section of the ENVIRONMENT DIVISION. An example may be similar to this using the correct device names for your case
OPERATOR-CONSOLE IS OUT-OP2 in special-names with DISPLAY "RUN ERROR - NO DETAIL RECORDS, ABORTING" UPON OUT-OP2 and
DISPLAY "REPORT TO OPERATIONS MANAGER" UPON OUT-OP2 and STOP RUN. in procedure division.
A reference to the circumstance would need to be included in any job or macro and operating instructions.
Yes, it is possible to abend your job intentionally through COBOL program by simply calling one module which doesn't exist. It will give S806 abend code.

Pretty Print for (Informix-)4gl code

i'm searching for a pretty print program (script, code, whatever) for Informix-4GL sources.
Do you know any ? Than you, Peter.
Have you looked at the IIUG (International Informix User Group) software archive? There are two pretty printers there (of indeterminate quality).
The other place to look would be the Aubit4GL site - an open source variant of I4GL. Again, I'm not sure that they have a pretty-printer, but it might be something they have (though a casual check doesn't show one).
I don't know if anyone is reading this post anymore, but the easiest way to get some kind of nice "pretty print" of 4gl code is to view it in the Openedge Developer Studio, then use ctrl-I to set indention. You can adjust indention in the editor settings by saying the length of "tabs". (default is 4, I use 3)
Then do a ctrl-shift-f to make all command words uppercase.
Next, you can condense the code a few lines by moving all the "DO:" statements up a line next to the "THEN" statement with this regular expression search and replace.
ctrl-f:
search "\s*\n\s*DO[:]"
replace " DO:"
make sure you click the checkbox marked regular expressions.
At this point the code is nice and tidy.
Do a ctrl-a and ctrl-c to copy it to the clipboard.
paste it in Outlook as an email without sending. Print it in color.

Sleep from within an Informix SPL procedure

What's the best way to do the semantic equivalent of the traditional sleep() system call from within an Informix SPL routine? In other words, simply "pause" for N seconds (or milliseconds or whatever, but seconds are fine). I'm looking for a solution that does not involve linking some new (perhaps written by me) C code or other library into the Informix server. This has to be something I can do purely from SPL. A solution for IDS 10 or 11 would be fine.
#RET - The "obvious" answer wasn't obvious to me! I didn't know about the SYSTEM command. Thank you! (And yes, I'm the guy you think I am.)
Yes, it's for debugging purposes only. Unfortunately, CURRENT within an SPL will always return the same value, set at the entry to the call:
"any call to CURRENT from inside the SPL function that an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement invokes returns the value of the system clock when the SPL function starts."
—IBM Informix Guide to SQL
Wrapping CURRENT in its own subroutine does not help. You do get a different answer on the first call to your wrapper (provided you're using YEAR TO FRACTION(5) or some other type with high enough resolution to show the the difference) but then you get that same value back on every single subsequent call, which ensures that any sort of loop will never terminate.
There must be some good reason you're not wanting the obvious answer:
SYSTEM "sleep 5". If all you're wanting is for the SPL to pause while you check various values etc, here are a couple of thoughts (all of which are utter hacks, of course):
Make the TRACE FILE a named pipe (assuming Unix back-end), so it blocks until you choose to read from it, or
Create another table that your SPL polls for a particular entry from a WHILE loop, and insert said row from elsewhere (horribly inefficient)
Make SET LOCK MODE your friend: execute "SET LOCK MODE TO WAIT n" and deliberately requery a table you're already holding a cursor open on. You'll need to wrap this in an EXCEPTION handler, of course.
Hope that is some help (and if you're the same JS of Ars and Rose::DB fame, it's the least I could do ;-)
I'm aware that the answer is too late. However I've recently encountered the same problem and this site shows as the first one. So it is beneficial for other people to place new anwser here.
Perfect solution was found by Eric Herber and published in April 2012 here: How to sleep (or yield) for a fixed time in a stored procedure
Unfortunately this site is down.
His solution is to use following function:
integer sysadmin:yieldn( integer nseconds )
I assume that you want this "pause" for debugging purposes, otherwise think about it, you'll always have some better tasks to do for your server than sleep ...
A suggestion: Maybe you could get CURRENT, add it a few seconds ( let mytimestamp ) then in a while loop select CURRENT while CURRENT <= mytimestamp . I've no informix setup around my desk to try it, so you'll have to figure the correct syntax. Again, do not put such a hack on a production server. You've been warned :D
Then you'll have to warp CURRENT in another function that you'll call from the first (but this is a hack on the previous hack ...).

Resources