Salesforce

How Do I Call a Program Dynamically By Its Index? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Call a Program Dynamically By Its Index? (Magic xpa 3.x)

You can call a program based on its index number. You can do this two ways, by using the Call by Expression operation, or by using the function CallProg().

CallProg() is useful when you want the program to execute within an expression, and you want to use the returned value as a parameter to another function.

Using Call by Expression

  1. Use F4 to create an operation.

  2. Press C for the Call operation. Tab to the next field.

  3. Select By Exp for the call type. Tab to the next field.

  4. Zoom to create an expression. The expression should be the program’s index number in quotes, followed by the PROG literal. We are calling program 61, so we entered '61'PROG.

Using CallProg()

  • In the Expression Editor, type in the function CallProg(‘n’PROG)

(where n is the program index) wherever you want the return value of the program. This could be as an init value, as an expression displayed on a form, or as part of another expression. Or, if the program has no returned value, you can use an Evaluate operation.

You can also use CallProg() in conjunction with the ProgIdx() function, to call the program from within an expression using the program’s public name.

These methods are mainly useful when you want to store the name or number of the program to call. For instance, you could create a table to allow the user to create their own private menu system.

Note: The PROG literal is what allows Magic xpa to keep the program number synchronized if the program happens to get moved within the Program repository. You can use the format CallProg(61) and it will function, but if program 61 gets moved to become program 65, the function will still be calling program 61.

Hint: This method is useful in combination with the ProgIdx() function, which returns the program index based on its public name.

Selecting the program

When you are selecting a program number, you do not have to memorize the number. For this, and other items you need to add to expressions, you can use the Program list that's available from the Expression Editor. For the examples above, to select the program number, you would:

  1. From the Expression Editor, after selecting the CallProg function, click the program icon from the toolbar or select Programs from the drop-down list. A list of programs will appear on the right side of the Expression Editor.

  2. Find the program that you want. You can use Locate (Ctrl+L) or go directly to the Search field, and then type the first letters of the program name, or just scroll, to position on the program you want.

  3. Click the Select button.

The program literal will be brought into your expression.

See also

The Online and Rich Client Samples projects (program EL11 and REL11)

Reference
Attachment 
Attachment