Tips: QM code in the forum (colors, functions, dialogs, etc)

New QM versions, other news. Forum rules and tips.

Tips: QM code in the forum (colors, functions, dialogs, etc)

Postby Gintaras on Sat Apr 01, 2006 11:45 am

Q. How to post QM code to the forum?
A. In QM, to copy all or selected text, use menu Edit -> Other Formats -> Copy for QM Forum. It copies correct and colored code to the clipboard. Then simply paste in the forum. Don't use the Code button.

Q. How to copy QM code in the forum, and then paste in QM?
A. In the forum, select code in white box and copy it to the clipboard (Ctrl+C). Then simply paste in QM. If displays link 'Click here to correct the pasted code' , click it.

Q. How to install and use functions and other code from the forum?
A. Read next post.

Q. How to use dialog examples? Where to place the code, etc?
A. Read this: viewtopic.php?p=8371

Q. Why QM code in the forum is with commas (,) and semicolons (;) instead of tabs and spaces?
A. Tabs and spaces may disappear when you post code in the forum. These characters are important. When you copy text using menu Edit -> Other Formats, it replaces tabs and spaces to commas and semicolons. When you copy forum code and paste in QM, QM suggests to correct pasted code, which restores tabs and spaces.
Last edited by Gintaras on Thu Apr 10, 2008 12:36 pm, edited 3 times in total.
Gintaras
Site Admin
 
Posts: 10385
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Installing and using functions and other code from the forum

Postby Gintaras on Sun Dec 02, 2007 10:55 am

Installing and using functions from the forum

Assume you have found code like this example:

Function GetWinXY
;/
function# hwnd [&x] [&y] [&width] [&height] [hwndparent]

;Stores window position and size to int variables x, y, width and height.
;Returns 1 if successful, 0 if not.


;hwnd - handle of the window. Can be top-level or child window.
;hwndparent - handle of the parent window. If used and not 0, the coordinates will be relative to the client area of hwndparent. Otherwise - coordinates in screen.


;EXAMPLE
;int x y cx cy
;GetWinXY(win("Quick Macros") x y cx cy)
;out "%i %i %i %i" x y cx cy



RECT r
if(!hwnd or !GetWindowRect(hwnd &r)) ret
if(hwndparent) MapWindowPoints(0 hwndparent +&r 2)
if(&x) x=r.left
if(&y) y=r.top
if(&width) width=r.right-r.left
if(&height) height=r.bottom-r.top
ret 1



Installing
1. Copy the code. To copy, select the whole white field and press Ctrl+C.
2. In QM, create new function. To create new function, click menu File -> New -> New Function. Name it GetWinXY, or whatever name is given above the code or in examples. If the name is not given, you can name the function as you like.
3. Paste the code in the new empty function. If displays 'Correct...' link, click it.

Learning
The code or/and the post usually contains information what the function does and how to use it. Only read the description. You don't have to learn or modify the code. Just ignore it.

Testing (optional)
1. Create new macro.
2. If EXAMPLE code is given in the function code, copy it and paste in the macro. If several examples are given, copy/paste one of them. To uncomment, select the code and right click the selection bar at the left.
3. Run the macro.

Sometimes example code is not within the function code, but somewhere else in the post. Copy it and paste in the macro. If example code is missing, create it. Examples:
FunctionName
FunctionName somevalue somevalue2
somevariable=FunctionName
somevariable=FunctionName(somevalue somevalue2)


Using in your macros
You can use the function in your macros, functions, menus, etc. Don't paste the code there, but instead use the name, like in examples. In most cases you should not run the function or assign a trigger, but instead run your macros that call the function.

Member functions
Member functions are installed like functions, except that you have to use menu File -> New -> New Member Function.

These functions usually have . in the name, for example str.FunctionName. The part before . is the type of variables with which the function can be used. Examples of calling the function when the type is str:
str s
s.FunctionName
s.FunctionName(somevalue somevalue2)
somevariable=s.FunctionName
somevariable=s.FunctionName(somevalue somevalue2)


What item type it is (function, macro, etc)?
Usually item type is given in the post. If not, usually you can understand from the code or from the comments. For example, if the code looks like the above example function, or just contains function at the beginning, it's probably function. Otherwise, if it's not menu or toolbar, it's probably macro.

Often there is only small code example, not entire function or macro. It can be placed anywhere. For testing, it is recommended to use a macro.

Triggers
Sometimes above the code is given the recommended trigger. It is encoded trigger string. Select the trigger string (not including "Trigger "), copy, and paste in QM, into the Trigger field. The trigger field is on the toolbar, between the Properties and Save buttons.

Attached files
Sometimes code is in an attached file, not in the post text. Then installing is easier. Download the file and open. It opens in the QM file viewer. Click Import. It creates the function(s) for you.

_______________________________________

Learn about functions:
http://www.quickmacros.com/help/QM_Help ... NTIPS.html
Gintaras
Site Admin
 
Posts: 10385
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Postby QM Assistant on Sun Dec 02, 2007 4:59 pm


That will be very useful for people who didn't know how to do that before. Explained very clearly.
User avatar
QM Assistant
Active Member
 
Posts: 470
Joined: Mon Aug 06, 2007 11:31 pm
Location: Michigan, USA


Return to QM and Forum Info

Who is online

Users browsing this forum: No registered users and 1 guest

cron