Paul Mulroney
Forum Replies Created
-
You need to do the following (assuming Studio 8.0 or higher):
Do $cdevice.$assign(kDevOmnisPDF) ;; Switch to the Omnis PDF device.
Calculate $prefs.$reportfile as ‘full path to PDF file’ ;; Omnis PDF uses the $prefs.$reportfile to determine where to write the PDF.
Print report -
We’re looking at the Studio 10 DML to SQL stuff, but there still seems to be a few issues. We’re working with tech support to get them resolved because we still have a few DML based clients that we’d like to get to PostgreSQL.
-
We’re looking at this for a jsClient project we’re doing for a client. I’m fairly sure it’s similar to the thick client.
-
Hi Everyone,
A quick update:
We’ve been able to get it working, using a HTTP Worker object, and a command line call to openSSL. There’s an Authorisation header that contains the URL of the request and a number of other fields. This is then signed using RSA-SHA1 and sent as part of the request.
This is our two lines of code that do the magic:
Calculate vsScript as con('cmd ',kDq,'/c ',kDq,kDq,isOpenSSLPath,kDq,' dgst -sha1 -sign ',kDq,vsKeyFile,kDq,' ',kDq,vsSrcFile,kDq,' | ',kDq,isOpenSSLPath,kDq,' base64 -A',kDq,kDq)
Launch program [vsScript] Returns vsSignature (Do not quit Omnis)
It basically does the following on the command line:
/path/to/openssl.exe dgst -sha1 -sign "/path/to/key/file" "/path/to/request" | "/path/to/openssl.exe" base64 -A
I don’t think this is a good long-term solution, because we’d be constantly opening a command window to run the signing/base64 conversion
I believe that Python has a lib that will allow us to do the same thing, but I have no idea how to call it from within Omnis.
Has anyone tried to sign something using RSA-SHA1 in Omnis? How do you do it?
Perhaps while you’re at EurOmnis, someone can figure out a quick and dirty hack for us!! -
Here’s another one:
There’s a problem with TCPPing on Studio 5.2, Mac OS Sierra and above – it always returns an error. I’ve created a workaround, and posted the code on GitHub.
NOTE: you don’t need to do this for Studio 8.0 and above, or for Windows/Linux, or for Mac OS before 10.12 (Sierra).
Here’s the link on Github: https://github.com/pmulroney/TCPPing_for_Studio5 -
Hi $All,
Here’s another one:
https://github.com/pmulroney/ListIntersect_for_Studio5
From the ReadMe:
ListIntersect
Omnis Lists are powerful constructs that allow us to manipulate data in memory. A common operation is selecting lines in the list, often based on another list. A fairly simple way to do this would be to have two nested loop operations like the following pseudocode:For vList1.$line from 1 to vList1.$linecount step 1
For vList2.$line from 1 to vList2.$linecount step 1
If vList1.field=vList2.field
Select list line(s) {#L}
End For
End ForFor this code, it executes the inner loop n x m times – where n = list 1 linecount, and m = list 2 linecount. If List 1 or List 2 are large, then you could be executing the inner loop millions of times, and take a significant amount of time to do so.
This is where the $ListIntersect() function comes in. This method has been written so that you only process the smallest list *once*, which results n a significant performance increase.
This is really cool, so if you’re going to pinch it, make sure you acknowledge us ok?
USAGE
oListInterection.$ListIntersect(plList1,plList2,psFieldname,psFieldtype)
IN:- plList1 – the larger of the two lists to process. It can have duplicate values in the column that you’re testing
- plList2 – the smaller of the two lists.
- psFieldname – the column name in the list that you’re comparing again
- psFieldtype – options are Char, Int, Num or Date.
OUT: All lines in list1 that exist in list2 will be selected in list1.
NOTE
Both lists will be sorted by the nominated field name.
The comparison column must be the same name/type in both lists.
EXAMPLE
See Example1 for a trivial example of this method in operation. For a given list of cities/states in Australia, only select lines for a number of cities
In our software we use it as part of our search filtering process for some reports.
AUTHORS
@pmulroney, submitted on behalf of Logical Developments
Contributing
1. Fork this repository
1. Add a branch for your feature
1. Add the feature and perform a new JSON export
1. Submit a pull request -
Hi $All
We’ve created a Github repository for a JSON parser written for Studio 5. Where’s the best place to announce it?
https://github.com/graemereid/JSON_for_Studio5
From the ReadMe:
JSON_for_Studio5
This library contains an Object class (oJSON) that is intended as a substitute for the built-in OJSON found in Studio 8. It arose from the need to parse and generate JSON in a project for a client that it still running in Studio 5. This is really cool, so if you’re going to pinch it, make sure you acknowledge us ok?
Usage
The oJSON object contains the following methods:
oJSON.$jsontolistorrow(psData[,&psErrorText])
Parse the JSON array or object in psData and return a row representing the JSON
IN: psData – JSON to parse, psErrorText – contains the error if parsing fails
OUT: vrJSON – row representing the JSON array or object, or NULL if parsing fails
oJSON.$listorrowtojson(prJSON)
Encodes the row representing the JSON array or object as a character string
IN: prJSON – row representing the JSON array or object
OUT: vsData – unformatted JSON
oJSON.$formatjson(psData)
Parses the JSON in psData and returns a formatted representation
IN: psData – JSON to format
OUT: vsData – formatted JSON or error message if parsing fails
oJSON.$couldbearray(psData)
Returns true if psData could be a JSON array because its first character is [
IN: psData – JSON to parse
OUT: kTrue if psData could be a JSON array
oJSON.$couldbeobject(psData)
Returns true if psData could be a JSON object because its first character is {
IN: psData – JSON to parse
OUT: kTrue if psData could be a JSON object
Note that there are a couple of (hopefully minor) differences between this class and the built-in class in Studio 8. Most of these are for features that we did not need for our project, so feel free to add them if you need them 🙂
In the Studio 8 version:- the $jsontolistorrow method takes an optional third parameter [bAllowArraysOrRows=kFalse]
- the $listorrowtojson method takes an optional second parameter [iEncoding=kUniTypeUTF8] and third parameter [&cErrorText]
- there is an additional method $arrayarraytolist(vData[,&cErrorText])
- there is an additional method $listtoarrayarray(lList[,iEncoding=kUniTypeUTF8,&cErrorText])
- there is an additional method $objectarraytolist(vData[,&cErrorText])
- there is an additional method $listtoobjectarray(lList[,iEncoding=kUniTypeUTF8,&cErrorText])
The parser is somewhat permissive, so it may successfully parse invalid JSON, and it does not handle escaped quotes within string literals. Also, it treats every literal as a string, rather than attempting to determine the type from the context.
The library also contains a Code class (TestJSON) with sample code to parse, encode, and format JSON.
Authors
@graemereid, submitted on behalf of Logical Developments -
Thanks for the feedback Alex – we’ll do that!
-
Hi $All,
We’ve written some code that mirrors the oJSON object in Studio 8, for use in our Studio 5 systems. We believe that this is something that other developers who aren’t using the latest and greatest may find useful.
It seems that the logical place to put this code is on GitHub, but the first pre-requisite is that you must be using Studio 8.1. It’s kind of a catch-22: if you have Studio 8.1, you don’t need routines to handle JSON, they’re built into Studio 8.
What’s the best way to share this code with the community? -
Hi Das!
Good to hear from you. Hope all is well with you. In answer to your questions:
1. Yes. While code can be executed on the jsClient, you can also execute code on the Omnis server that the jsClient is connected to.
2. Yes. It’s not the preferred setup – Code Classes are considered to be “not good Object-Oriented design”. That being said, if you’re converting your app to a more modern setup, code classes can be a stepping stone into the Object-Oriented world.
3. No. No copy/paste from thick client window objects to remote forms. You have to remake your interface using the objects specifically made for the remote form. You could consider writing some code to do the work for you, and create an equivalent of each field in the remote form, but what you find is that the remote forms don’t work quite the same way as a window would. Depending on how your thick-client application works, there could be huge differences between the two.
4. No. There is a “Background object”, which can be set to be a line, or a circle, rectangle, image etc.
5. Yes. Keep in mind, unless you’re deploying a “serverless client”, you need an Omnis Server running somewhere that your jsClient connects to. That’s where the externals etc are installed.
6. I suspect the mailing list 🙂
Regards,
Paul.