/// <summary> /// the programs constructor. This is where you want to do all the setup for your runtime environment, preferably all your code. /// </summary> Program() { // create a dictionary mapping from a jobs name to job objects // the interval will get sanitized to multiples of possible programmable block update frequencies var jobDict = new Dictionary <string, RuntimeEnvironment.Job>() { { "jobname", // the name your job uses. used for output. new RuntimeEnvironment.Job( _Action: MyJobFunction, // the function to be called when your job is active. Needs to be "state machine compatible" _RequeueInterval: 22, // after how many ticks function will get executed again. this gets sanatized to multiples of 1,10 or 100 _active: false, // is your job active from the start? _lazy: true, // if true, your job will not switch the Environment into a fast tick mode (assuming it isnt already at updatefrequency 1) _AllowToggle: true, // is the user allowed to toggle your job off, using the "toggle" command? _AllowFrequencyChange: true // is the user allowed to change the frequency of your job using the "frequency" command? ) } }; // create a dictionary mapping from a commands name (i.e. the part before the first space, if any) to command object var commandDict = new Dictionary <string, RuntimeEnvironment.Command>() { { "command", //the string that should be the first part of your command. no spaces allowed new RuntimeEnvironment.Command( _Action: MyCommandFunction, // the function to be called when the string is encounted _MinumumArguments: 0, // the minimum number of arguments (apart from itself) your command expectes. 0 is the default _UpdateType: UpdateType.Terminal // the update type your command will be run on. defaults to a user pressing the run button ) } }; // create the Environment with a reference to the Program Env = new RuntimeEnvironment( _ThisProgram: this, //you need to hand over a reference to the calling program so the environment can control frequencies _Jobs: jobDict, //the dictionary you created above _Commands: commandDict, //OPTIONAL: the command dict you created above _EchoState: true, //OPTIONAL, default false: whether the enviroment should display its state in the terminal every tick _DisplayState: true //OPTIONAL, default false: whether the enviroment should display its state on the running PBs screen every tick ); //the environment can load its state from the PBs internal Storage String, assuming you did save it. Echo("test"); Env.LoadFromString(Storage); }