$04 Suppressing OK message

Ben Price ben at clintelsystems.com
Sun Jun 26 20:43:55 EDT 2016

Hi Marten,

I understand your concern. Doing a find replace on all classes in an 
25mb Omnis library caused instability within instantiated objects (as 
code base changes behind them) causing Omnis to crash.

Replacing 3000 OK box lines to a custom method when all options are used 
and different is a lengthy task which managers do not want to invest in. 
I do agree best practice would be to do your suggestion.

My solution was to make a duplicate library (programmatically) do a find 
and replace on all classes in duplicate library as well as changing the 
library $startuptaskname so on launching the duplicate library only my 
procedure runs. After procedure is finished it relaunches the main 
library (which deletes the duplicate)

It is not pretty but it was quick to implement.

It has also helped me get around Omnis "Out of Memory" error which 
seemed to occur after reading / updating more than 1000 pdf snapshots 
through the Omnis studio 4 Postgres driver. (I seem to be getting a 
memory leak)

Old list posts suggest doing this in batches of 500 records, before 
restart (or update your Omnis studio to a newer version - which i am 
unfortunately unable to do)

So I am using an external program to launch Omnis if it is not running. 
This allows Omnis to processes 500 records before closing which is 
stopping if from crashing.

All the best,

Ben Price
Software Engineer
p: (08) 8203 0550

On 23/06/2016 22:29, Marten Verhoeven wrote:
> Hi Ben,
> First of all: I don't think you should do this at all. It is bad code because you are building a quick and dirty solution. If you often use these solutions your code will get really hard to maintain and expand. The proper way to do things is to separate the functionality from the user interface. You call the functionality from the user interface (and show dialogs there when needed), or you call the functionality from your automation routines. You are better off investing your time in such a cleaner design.
> That said: you cannot prevent the built in message boxes from popping up, but you can when you use your own message box. If you wrap this message box in your own message object, you can create some kind of global flag which tells the object to suppress all messages (and therefor will not show them when you set the flag at the start of your automation procedure).
> And the nice thing of Omnis is: you can easily create a function which replaces all use of the built in message boxes with your own implementation. I did the exact same thing when I wanted to change the message box design and wanted to implement multi language support. The function I created went through all of my source code and replaced the built in message boxes, extracted all texts from it and created proper string-tables to access them. From then off you have your own implementation so it is easy to add functionality to it (for example have a button to specific help pages when an error occurs).
> With kind regards,
> Marten Verhoeven
> -----Oorspronkelijk bericht-----
> Van: omnisdev-en [mailto:omnisdev-en-bounces at lists.omnis-dev.com] Namens Ben Price
> Verzonden: vrijdag 17 juni 2016 8:05
> Aan: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
> Onderwerp: Re: $04 Suppressing OK message
> Hi List,
> I think I have found a solution but it's not pretty (an elegant solution would be preferable) and I hope my interpretation of $findreplace using regex works!
> On loading my automated task I can loop through all $clib.$classes and call $findreplace('^.*OK Message.*$','^;.*OK Message.*$',ktrue,kfalse,
> ktrue) on each class which should comment them all out.
> At the end of task I can then  $findreplace('^;.*OK Message.*$','^.*OK Message.*$',ktrue,kfalse, ktrue) to put them all back.
> --
> All the best,
> Ben Price
> Software Engineer
> p: (08) 8203 0550
> On Fri, Jun 17, 2016 at 3:12 PM, Ben Price <ben at clintelsystems.com <mailto:ben at clintelsystems.com>> wrote:
>      Hi List.
>      I have written a automated process which opens up windows and prints
>      records, but on any one of the windows an OK box may be presented to
>      the user if the data or setup for the data is incorrect.
>      Is there any way in Omnis 4 to be able to suppress OK messages so
>      automated process to operate without user intervention?
>      --
>      All the best,
>      Ben Price
>      Software Engineer
>      p: (08) 8203 0550
>      _____________________________________________________________
>      Manage your list subscriptions at http://lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com

More information about the omnisdev-en mailing list