How can I define an Enum global to use it outside of the defined scope? I created a script which imports another script (including all global functions, variables and enums)
Enum CrudFlag
{
Undefined
Create
Read
Update
Delete
}
You have to import your script using dotsourceing:
Each script runs in its own scope. The functions, variables, aliases, and drives that are created in the script exist only in the script scope. You cannot access these items or their values in the scope in which the script runs.
To run a script in a different scope, you can specify a scope, such as Global or Local, or you can dot source the script.
The dot sourcing feature lets you run a script in the current scope instead of in the script scope. When you run a script that is dot sourced, the commands in the script run as though you had typed them at the command prompt. The functions, variables, aliases, and drives that the script creates are created in the scope in which you are working. After the script runs, you can use the created items and access their values in your session.
To dot source a script, type a dot (.) and a space before the script path
Source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With