Tips   >   About   >   Hot Tips and Tricks
You can break into the method editor and continue stepping through the code from any OK, Yes/No, No/Yes, Prompt for Input dialog window.
When the prompt dialog window is open, depending on your platform press the following key(s):

Use OK messages to assist with debugging by adding OK messages into your code which report the method being executed and the values you want to watch. Run the process you are trying to debug and at any one of the OK messages you can break into the code and continue stepping through the code in the method editor.
I like to include @DEBUG in the title of any debug OK messages so that I can easily search for @DEBUG to find and remove them later on.
You can change some of the Omnis commands without losing the calculations or text which you've entered. You can:
You can change the scope of any variable by dragging it from one tab pane to another tab pane of the pane in the method editor.
If you are decreasing the scope from a class or instance variable to a local or parameter variable you might get a message that tells you that the scope can't be changed while the class is open. If this occurs use the menu to , then try again.
If you are decreasing the scope of a variable it can't be in more than one method and you must have that one method selected at the time you decrease the scope.

If you are changing the scope of a class variable or instance variable, make sure you don't have any subclasses which are using that variable! The subclass methods will not be aware of the change. The next time you look at the subclass method, those variables will be prefixed with $cinst. and your subclass method code will be broken.
A situation where this trick comes in useful, is if you have a very long method which you want to break down into several submethods in the same class, or even into a separate object class.
Omnis Studio notation methods displays in plain brown text in the method editor.
Custom methods display in bold green text in the method editor.
If you misspell an Omnis Studio notation method it displays in bold green text. Once you pick up on this you can immediately notice if you've correctly or incorrectly typed an Omnis Studio notation method.
; $doesfileexist is displayed in plain brown text.
Do FileOps.$doesfileexist(Path) Returns bFileExists
; Misspelled $doesfilexist (missing the double 'ee') is displayed in bold green text.
Do FileOps.$doesfilexist(Path) Returns bFileExists
I use this trick a lot if I decide to change a kEntry field to a kMaskedEntry field or a kMultiline field.
You can cycle through the open IDE windows using a shortcut key combination.
You probably already know about this trick because it is used in lots of drawing program... but in case you don't here it is.
To copy an existing field in a window.
You can commnet out a line of code in the method editor, edit the code as text, and then uncomment the line of code.
A couple of situations where I use this trick:
The steps for editing code as text are shown in the following example.
Do iList.$search($ref.ColName=Value,1,0,0,0) Returns LineNum
If LineNum
; Do something
End If
; Do iList.$search($ref.ColName=Value,1,0,0,0) Returns LineNum
; If iList.$search($ref.ColName=Value,1,0,0,0)
If iList.$search($ref.ColName=Value,1,0,0,0)
; Do something
End If
The is loaded with , , and other goodies which you need to know about when writing code. A very cool feature of the is that you can drag any function along with its parameters directly into your code.
Be sure you have tooltips enabled! Hovering over a function or other item displays a tooltiip with more information. Right-click on the to set it and then right-click and after you have it set.You can use the Omnis Studio Find and Replace tool on selected lines in the method editor. As situation where I use this trick is if I copy a block of code from one method to another, but after copying the code I see that one of the variables used in the pasted in section of code needs to be change to the name of a local variable already included in the existing method. The steps for changing the variable name in pasted section of code area as follows:
Find and relace selected lines... a handy feature of OMST!

You can remove selected log lines by right-clicking and selecting .
After you enter a line of code Omnis Studio automatically corrects the case (upper or lower) of any characters in variables you type in your code to match the declared variable.
If you have variable named iBooksList and you enter ibookslist in your code, Omnis Studio will change ibookslist to iBooksList after you press the key or move to a different line in the code list.
If you are editing an existing line of code, you can intentionally type the variable name in all lower case characters and then watch as you press the Enter key to make sure Omnis Studio changes the case. If the case is changed you know you've correctly entered the variable name.
; There is no variable declared named 'iBookList' (singular)
Do ibooklist.$search(kTrue)
; There is a variable named 'iBooksList' plural.
; After I change 'ibooklist' to 'ibookslist' and press the Enter key
; Omnis changes the case to match the declared variable.
Do iBooksList.$search(kTrue)
If you aren't using the , then you are missing a powerful tool in Omnis Studio which can assist you greatly in writing your code.
The lets you look at all the public methods of a class, their parameters, and description.
You can drag methods from the directly into your code along with the list of parameters.
To learn more, go throught the StudioTips . The time you take to go through the tutorials will pay back in the time you save over the next month of writing your own code.Omnis Studio allows you to find and jump to lines of interest in the list, list, and list:
If are in the method editor of a sublcass and want to look at the code in the superclass here are a few tricks for getting to the superclass method.

If I don't have a Do inherited in the overridden method code, I will often add one at the end of the method after a Quit method command.
; Subclass method code of an overridden superclass method.
Do iList.$definefromsqlclass('SomeTableClass')
Quit method kTrue
; Include this line AFTER the Quit method.
Do inherited
; Select the above line and press F8 to jump to superclass method.
If you want to move some of the field from one tab to another tab of a tab pane object.

If you hold down the Ctrl/Opt key while dragging the fields, they will be copied to the other tab.
If you want to catch errors in your notation be sure to set the library preference $reportnotationerrors to kTrue for every one of your libraries.
If you have calls to custom methods which may or may not exist, use $cando to test for the existence of the method before calling it. This will avoid hitting a notation error for those optional custom method calls.
; Optional call to a custom method which might not exist.
If $cinst.$OptionalCustomMethod.$cando
Do $cinst.$OptionalCustomMethod() Returns FlagOK
End If
Set the notation helper to respond really, really, fast so that you don't have to pause for it to help you when writing your code.
If you aren't using the , then you are missing one of the more powerful tools in Omnis Studio which can assist you in writing your code. Coupled with the they a great team. The Notation Inspector lets you brower everything in your Omnis Studio application and the r tells you all the methods and properties for anything you select in the .
You can drag properties or methods from the directly into your methods.
To learn more, go throught the StudioTips . The time you take to go through the tutorials will pay back in the time you save over the next month of writing your own code.I like to include the following $ping method in the class methods of all my object, window, and table classes.
; Return true. Open OK message if not(pbSilent).
If not(pbSilent)
OK message Ping (Icon) {$ping message received by... ////$lib: [$cclass.$lib().$name] ////$cclass: [$cclass().$name] ////$cinst: [$cinst().$name] ////$container: [$cinst.$container().$name]}
End If
Quit method kTrue
If you are debugging and want to test sending a message to a class instance the $ping method is a handy way to jump into the class instance's class methods.
Do $clib.$windows.wWinClassName.$openonce() Returns rWin
If rWin
; Test sending a ping message to the window.
Do rWin.$ping() Returns FlagOK
End If
I sometimes use the $ping method with the pbSilent parameter set to kTrue in order to test for a valid instance in my runtime code as follows:
; Dynamically point a variable to an object class instance.
Do $clib.$objects.oObjectName.$new() Returns oObjInst
; Test for a valid instance using the $ping method.
Do oObjInst.$ping(kTrue) Returns FlagOK
If not(FlagOK)
OK message Error (Icon) {Unable to $ping the object instance.}
Else
; Continue
End If
Quit method Flag
The StudioTips menu has some handy menu lines which you can use for testing code.
This trick is great a great help for developer testing and debugging! I put the following code in the $event method of all my pushbuttons.
On evClick
If #SHIFT
Breakpoint
End If
This allows me to hold the shift key down when I click on any pushbutton or toolbar button and very easily break in and start stepping through the code.
To save having to copy and paste the code into each pushbutton, you can add the code to the pushbutton in your as follows:
On evClick
If #SHIFT
Breakpoint
End If
The next pushbutton you drag out of the will include the code you just added to the $event method.
I also include the If #SHIFT Breakpoint End if code in the $event method of my tab pane objects, just after On evTabSelected. This allows me to break into my code by shift+clicking on a tab.
An extension of this trick is to include on all your window classes a tiny pushbutton which is only visible to developers. You add a $construct method to the pushbutton and put the following code in the button to hide it from non-developers.
; $construct method of Programmer Test pushbutton
; Hide the pushbutton from non-developers.
If sys(2)<>1
Do $cfield.$visible.$assign(kFalse)
End If
Trying to select a group of fields which are inside a container field (Paged Pane, Tab Pane, Group Box, Scrollbox) can be a real pain. If you try to drag a rectangle marque around the fields, the container field gets selected and you never get a chance to draw the marque rectangle around the fields inside the container.
Hold down the Ctrl/Cmnd key and you will be able to drag a marque around the field inside the container field without selecting the container field.Do you ever want to get to the methods of a window instance without breaking the instance?
The StudioTips menu line in the menu does this for you.
If you are reading this tip in the , press Ctrl/Cmnd+Shift+T right now. This is the shortcut key combination for the menu line. (Think of it as an alternate to Ctrl/Cmnd+T)
Once you are behind the window instance, you can select a method, set a red breakpoint, then close the method editor and run the method from the instance. When code execution reaches the red breakpoint the method editor will open at that point and you can continue stepping through the code.