PICScript - Example Global Variable Script

This example script demonstrates:

//GridScriptMode

// This is a comment line

// This script will blank out picks that are more than 50 meters

// shallower or deeper than the average depth of the surface.

//

// DECLARATION SECTION

// Declare input horizon and alias

surfacein C_38_DW1 from depth as GridDepth;

// Create globals to compute the

// average depth, initialize to 0

global count = 0;

global total = 0;

global average = 0;

// Define the output attribute

output depth;

//

// FUNCTION SECTION

// First pass to collect information,

// and compute average from live data.

func{

if(!isnopick (GridDepth)){

total = total + GridDepth;

count = count + 1;

average = total / count;

}

}

// Second pass to use that information

func{

if ((GridDepth < (average - 50)) || ((average + 50) < GridDepth)){

// The depth is outside 50 meters of the average

// Set it to a no pick

depth = setnopick (GridDepth,on);

}else{

// Use value from GridDepth

depth = GridDepth;

}

}