The P# Editor allows you to create, modify, run, save and share scripts.
The P# Editor can be found in the Build Section under Develop in PetroVisor.
PetroVisor's P# Editor is made up of the following parts:
New P# Script
Opens a new, blank script.
After creating or editing, saves the currently open script. The carrot will drop down and allow for Save As: saves the currently open script with a different name. It also has rename which allows to save the current script with a new Name
Deletes existing scripts.
Private vs Public
Make scripts visible by clicking the person icon. It will allow all users in that workspace to see the script
There are three run options in the P# script editor:
- Run executes the current script, creates columns and tables but does not save anything.
- Run with saving saves all new and modified signals to the database. Typically, while scripting only Run is used to test the script. Once the script is finished and generates proper results, Run with saving can be used to keep results.
- Run using scenario run lets the user choose an already saved scenario. The script is then executed using the values stored in that scenario, rather than the normal values, as stored in the database. If not all of the signals used in the current script are part of the selected scenario, PetroVisor will use the normal ones then. Note: If none of the signals is saved as part of the selected scenario, PetroVisor will take all signals from the normal database. The results will then be similar to those gained from using the simple Run option.
- To ease and increase speed of scripting, library can be used. They can be accessed via the Library icon on the right side of the P# editor. P# snippets are text modules of most widely used functionalities, which can be continuously expanded (Extract function in P# snippet window). Key words like Context, Entity Set, Scope, Table or Column automatically insert snippets when TAB is pressed after the last character of the keyword.
- The library is organized in these groups:
- Entity Sets
- These tasks can be performed in the Snippets panel:
- drag and drop a snippet into the Code canvas to use it in your code
- New: creates a new snippet
- Modify: allows you to edit existing snippets
- Delete: deletes the currently selected snippet
- Extract: automatically extracts snippets from the currently open script and saves them
- This is where the code is written
- In P# syntax, key words are highlighted in dark blue, functions in light blue, strings in red, and comments in green.
UnitsPetroVisor stores signals in standard units but automatically converts them to the assigned unit. To avoid confusions, it is important that the displayed unit equals the loaded unit. To ease programming in P#, the consistency of these units is not checked. However, especially in the beginning, this may be a possible pitfall.
CTRL+H: Find and Replace
CTLR+SHIFT+S: Save as
CTLR+SHIFT+Space: Brings up function description
CTRL+O / CTRL+L: Load
SHIFT+F5: Run with Saving
CTRL+A: Select All