[SOLVED] How can I make an include file for my scripts - SOLVED THANKS

I am having a lovely time playing with a script that draws a sonar for an Arduino output.

My script runs, I can read my Arduino outputs over the serial port, my sonar gets drawn.

I created some variables that I decide could be put into an include file that I could drag into other scripts but I cannot find anywhere that provides me with an example of how to do it so maybe you cant have include files and have to use import files, so I looked for a nice easy example of how to do that, couldn’t find anything,

So, can some one point me to where I can see an example of how to make an include or import file that contains variables that can be used in multiple scripts.

Additionally, is there a repository of samples/uploads of scripts that others have written

as to the include/import/library I am looking for something like

create a file something like
variables.h

color light_green = color(204, 255, 209);
color black = color(0, 0, 0);
color white = color(255, 255, 255);
 
color red = color(255, 0, 0);
color green = color(0, 255, 0);
color blue = color(0, 0, 255);

place in the script file
include variables.h

1 Like

you have just to create a “variables.pde” file and put in your main skecth folder.

all the others pde source files automatically will see the contents of “variables.pde” without the need to use a clause as #include.

2 Likes

My personal experience when transitioning from C like languges to Processing has been to create 3 files to better organize my projects :

  • headers.pde ( where i put all the imports of the libraries that i need )
  • const.pde ( where i put all const values )
  • globals.pde ( where i put global variables )

anyway this is just my personal way to do it.

1 Like

variables.pde Awsome, works a treat.

I took that information and went looking for it on the web and was pointed to http://processingjs.org/learning which had an example of using a pde file.

Thank you very much!!!

1 Like