<beginfold id='1'>/*</beginfold id='1'>Basic test file
Written by Julian Stirling, 2018
License: MIT<endfold id='1'>*/</endfold id='1'>

// This is a comment
x=5;
y=6;
z=5;
r=2;
for (n = <beginfold id='2'>[</beginfold id='2'>-1.5:1:1.5<endfold id='2'>]</endfold id='2'>)<beginfold id='3'>{</beginfold id='3'>
    translate(<beginfold id='2'>[</beginfold id='2'>n*x,0,0<endfold id='2'>]</endfold id='2'>)<beginfold id='3'>{</beginfold id='3'>cubehole(<beginfold id='2'>[</beginfold id='2'>x,y,z<endfold id='2'>]</endfold id='2'>,r);<endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

module cubehole(size,holerad)
<beginfold id='3'>{</beginfold id='3'>
    $fn=28;
    difference()
    <beginfold id='3'>{</beginfold id='3'>
        cube(size,center=true);
        cylinder(size<beginfold id='2'>[</beginfold id='2'>2<endfold id='2'>]</endfold id='2'>+1,r=holerad,center=true);
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

// some examples adapted from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
cube(5);
x = 4 + y;
rotate(40) square(5,10);
translate(<beginfold id='2'>[</beginfold id='2'>10, 5<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
    circle(5);
    square(4);
<endfold id='3'>}</endfold id='3'>
rotate(60) color(<beginfold id='4'>"</beginfold id='4'>red<endfold id='4'>"</endfold id='4'>) <beginfold id='3'>{</beginfold id='3'>
    circle(5);
    square(4);
<endfold id='3'>}</endfold id='3'>
color(<beginfold id='4'>"</beginfold id='4'>blue<endfold id='4'>"</endfold id='4'>) <beginfold id='3'>{</beginfold id='3'>
    translate(<beginfold id='2'>[</beginfold id='2'>5, 3, 0<endfold id='2'>]</endfold id='2'>) sphere(5);
    rotate(<beginfold id='2'>[</beginfold id='2'>45, 0, 45<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
        cylinder(10);
        cube(<beginfold id='2'>[</beginfold id='2'>5, 6, 7<endfold id='2'>]</endfold id='2'>);
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

aNumber = 42;
aBoolean = true;
anotherBoolean = false;
aString = <beginfold id='4'>"</beginfold id='4'>foo<endfold id='4'>"</endfold id='4'>;
aRange = <beginfold id='2'>[</beginfold id='2'>0: 1: 10<endfold id='2'>]</endfold id='2'>;
aVector = <beginfold id='2'>[</beginfold id='2'>1, 2, 3<endfold id='2'>]</endfold id='2'>;
aUndef = undef;
moreNumbers = <beginfold id='2'>[</beginfold id='2'>-1, 42, 0.5, 2.99792458e+8, 1.337e3, 314e-2<endfold id='2'>]</endfold id='2'>;
echo(moreNumbers)
echo(<beginfold id='4'>"</beginfold id='4'>The quick brown fox \tjumps \"over\" the lazy dog.\rThe quick brown fox.\nThe \\lazy\\ dog. \x21 \u03a9 \U01F98A \U01f43e<endfold id='4'>"</endfold id='4'>);

vector1 = <beginfold id='2'>[</beginfold id='2'>1,2,3<endfold id='2'>]</endfold id='2'>; vector2 = <beginfold id='2'>[</beginfold id='2'>4<endfold id='2'>]</endfold id='2'>; vector3 = <beginfold id='2'>[</beginfold id='2'>5,6<endfold id='2'>]</endfold id='2'>;
new_vector = concat(vector1, vector2, vector3); // [1,2,3,4,5,6]

string_vector = concat(<beginfold id='4'>"</beginfold id='4'>abc<endfold id='4'>"</endfold id='4'>,<beginfold id='4'>"</beginfold id='4'>def<endfold id='4'>"</endfold id='4'>);                 // ["abc", "def"]
one_string = str(string_vector<beginfold id='2'>[</beginfold id='2'>0<endfold id='2'>]</endfold id='2'>,string_vector<beginfold id='2'>[</beginfold id='2'>1<endfold id='2'>]</endfold id='2'>); // "abcdef"

a = <beginfold id='2'>[</beginfold id='2'>1,2,3<endfold id='2'>]</endfold id='2'>; echo(len(a));   //  3

// Example which defines a 2D rotation matrix
mr = <beginfold id='2'>[</beginfold id='2'>
    <beginfold id='2'>[</beginfold id='2'>cos(angle), -sin(angle)<endfold id='2'>]</endfold id='2'>,
    <beginfold id='2'>[</beginfold id='2'>sin(angle),  cos(angle)<endfold id='2'>]</endfold id='2'>
<endfold id='2'>]</endfold id='2'>;

// modifiers
% cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // background
# cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // debug
! cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // root
* cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // disable

// if example taken from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Rounding_examples
if(a==b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a==b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else if(a>b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a>b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else if(a<b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a<b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>???<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>

// assert example taken from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#assert
module row(cnt = 3)<beginfold id='3'>{</beginfold id='3'>
    // Count has to be a positive integer greater 0
    assert(cnt > 0);
    for (i = <beginfold id='2'>[</beginfold id='2'>1 : cnt<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
        translate(<beginfold id='2'>[</beginfold id='2'>i * 2, 0, 0<endfold id='2'>]</endfold id='2'>) sphere();
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>
row(0);
