Moving to Studio, what do I do with square bracket calls?

Doug Easterbrook doug at artsman.com
Sat Aug 18 13:44:27 EDT 2018


that looks like a menu …..   from memories of long time ago, that was a way to separate the code from the window - I think we all practiced some form of that dark art.

today that becomes an object

so if you put that code in an object and instantiate it


you would have something like

instantiate the object..

or it its kind of global thing, you can define it as a task variable  eg

taskvar    tMenu1    Object      (basded on opbject   PB_MENUE_NAME1


then its as simple as doing one or the other beliow

do  tmenu1.$install       (uses a direct reference)


or, if you want to do [] notation, you set the reference to the object … and then call it.

set myRef to   tMenu1
do   myref.$install


so instead of passing in a name of a menu,  you pass in its reference..   Note that you can pass a name as a parameter and then look up in the $clib for the actual object reference using notation.



and typically, you leave the state of the object inside the object so you might, in the $incstall method


$install

if PB_AM_I_INSTALLED
 then quit kfalse
else
  do the install stuff code
end if.



Those are breafcrumbs on how you might appraoch it …  if you are up to some change





ON THE OTHER HAND …..   can you do a

Call procedure [PC_Menu_Name]/$install

yes, you can call code like that AS LONG AS IT IS A CODE METHOD.  You can’t call it if its a menu since its not instantiated.   Meaning…. copy all your menu code and paste into a code method class.

be warned that code classes behave like Omnis 7 and there is little variable isolation and no way to instantiate the code class.   it is, by far, the closest to omnis 7 way of doing things that I’m aware of..




If you want to leave it in a menu class, you have to get it instantiates and then it should it be, at the very least, the following, probably

do $clib.$imenus.[PC_Menu_Name].$install




thats a quick overview..   there is more to it that n that..

but the gist, on converting is

a) do I want to simply make the code work and fix later — yes use a code class

b) do I want to keep the code in the same types of objects as omnis 7 — then you are using a menu class and you have to go about getting it instantiated and usable.

c) do I want to use that same code over and over and is it similar for different things I do…  then you are looking at an object or a table class and a bit of a reorganization.







the approach you take is dependant on the goal.     when we converted to studio, we kept on saying — I’m writing this code many times.   I’m copying it many times….. and we fell into the pattern of rewriting as objects…      much to our chagrin in the short term but to great pleasure in the long term.



recap:   be sure of your goals in the rewrite ..     and code class might be your friend.




Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On Aug 17, 2018, at 6:13 PM, Jim Creak <jim at jacsoft.co.nz> wrote:
> 
> I’m constantly being told that I need to move my Classic Omnis libraries into Studio, and I don’t dispute this, so I would like to prepare my Classic code so that moving into Studio will be easier.
> 
> In many places within my programs I use square brackets to call routines within other windows, as a simple example I have a routine that allows me to install a specified menu:
> 
> Parameter PC_Menu_Name (Character   10000000)
> Parameter PB_Install (Boolean)
> Other parameters are optional
> Parameter PB_Leave (Boolean) = kTrue     ;; If installed, Leave it
> ;
> Call procedure [PC_Menu_Name]/$installed
> If #F<>PB_Install
> 	If PB_Install
> 		Call procedure [PC_Menu_Name]/$install
> 	Else If not(PB_Leave)
> 		Call procedure [PC_Menu_Name]/$remove
> 	End If
> End If
> Quit procedure
> 
> My question is “Is there a way in Studio to do Square brackets in Call procedures, or will I need to rework it all some other way?”
> 
> As specified at the beginning of the email, I’m looking at trying to get my current working Classic system, which is still being developed on, ready for a smoother transition into studio. So would like to be able to add Studio specific code in where possible to help with this.
> 
> Thanks
> Jim
> 
> JACSoft Programming Ltd. <http://www.jacsoft.co.nz/main.shtml>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com



More information about the omnisdev-en mailing list