Sunday, September 30, 2007

Drag and Drop



These few video tutorials show you how the script editor in Ecotect makes it extremely easy to write scripts using the "drag and drop" style code editor.



first you will open the ecotect script editor



to start you will want to write this simple framework for exporting data to a txt file.

the code will look like this.

filename = getUserFile(1, "Save Script Output to...")

file = openfile (filename, "w")

write(file, "Print this text to the selected file.")

closefile(file)



next you will want to use the drag and drop code editor to drop in some predefined code that iterates though the analysis grid in ecotet.

under the script editor language help you will go to Example Code templates > User Defined Templates > Customizing your templates > Cycle through grid data and drop that item into your editor window.

when you are done your code will look like this...

filename = getUserFile(1, "save script output to....");

file = openfile (filename, "w");

x,y = get("grid.size")
print("Cells", x, y)

for j = 0, y-1 do

line = ""

for i = 0, x-1 do
value = get("grid.cell", i, j, 0)
line = line..format("%0.4f, ", value);
write(file, value);
write(file, "\n");
end

print(line)

end


closefile(file);

No comments: