Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling a Label
Is it possible to CALL a LABEL, where this LABEL will return to the originating LABEL?
Do you mean something like GoSub in Basic? No. The only choice is to call a function.
Yessss, something like that Big Grin

Functions does not have to return a value does it?

Also, all my macros are in the same file, is there a way to call another macro from another macro? I found the RUN command but it says it will run a separate file.

In QM, you can create items of several types: "Macro", "Function", "Toolbar", etc. When you want to create an item that can be called from code, choose "Function".

Simplest example: how to create function "Add" that would add A and B (A and B can be any integer values, eg simple numbers, variables, functions).

1. Click menu File -> New -> New function. This will create new item of type "Function". Name it "Add".
2. Use "function" statement to define arguments. It isn't necessary if function doesn't have arguments.
3. Use "ret" statement to return (exit) and optionally return a value. If function doesn't explicitly return anything, it actually returns 0.

Copy      Help
function'int int'A int'B
int C=A+B
ret C

function'int defines that type of function's return value is int;
int'A and int'B define arguments A and B, of type int. They are variables that receive values when function is called.

To call this function from a macro, use function's name, and two values for arguments. Example:

Copy      Help
Add 10 20

If you want to use function's return value, enclose arguments in parentheses. Example:

Copy      Help
int i
i=Add(10 20)

When you call a function, caller (macro) waits until the function returns. Function is like part of caller. However, function doesn't know anything about caller's variables, and vice versa. Caller and function can communicate through arguments.

To start another item (macro, function, toolbar, etc) asynchronously, use "mac" command.

Forum Jump:

Users browsing this thread: 1 Guest(s)