For example, Form files are handled differently the ps1 files.
Now that you know how to pass values to a form, how do you get values back? Returning values depends on what you are referencing. Note: Script scope variables can also be used as an alternative to parameters. Once you add the parameter block, PowerShell Studio will color the parameters accordingly: It is very important that nothing but comments appear before the parameter block. To do this, go to the form file’s script section and insert a Parameter block at the very top of the script. In these situations, you can use a parameter block in the same manor you would with a traditional ps1 script. There are times when you need to pass information to a child form. In addition, PowerShell Studio’s PrimalSense will display a list of Reference Functions when you type “Call-” : If you are unsure of the Reference Function name, you can look at the Reference Name property of the project file: Note: You can still dot source ps1 files but if you do you must set the ps1 file’s Build setting to Content so that it isn’t merged into the final project script. This allows you use the file’s reference function to execute it: Call-MyScript_ps1
If you need to call a ps1 file you will have to set the following project file’s properties in the Project Panel as follows: Propertyīy setting the CommandExtension property to False, you are telling the project to treat the ps1 file as a function. A file’s Reference Function uses the following naming convention: Call-_įor example, to call the AddExtension.pff file in the sample project, you would use the following reference function: Call-AddEmployeeForm_pff
To do this, you must use the Form’s Reference Function. Once you have a project with a form, you can call the form from the Startup.pfs or from another form.
At the end of this article there is a link to download a sample project that demonstrates how to use these techniques.Ĭalling Forms in a Project (Reference Functions) The Multi-Form Project template is a good starting point. You will need to create a project with multiple forms in order to proceed. In this article, we will answer these common questions in order to give you a better understanding about how to use projects with multiple forms. Two frequent questions we get on the forums are: