# 變數

``````my_text = "Hello, OpenSCAD!";
step_angle = 30;
height = 5;
``````

OpenSCAD is a Functional programming language, as such variables are bound to expressions and keep a single value during their entire lifetime due to the requirements of referential transparency.

``````x = 1;
echo(x); // 顯示 2
x = 2;
echo(x); // 顯示 2
``````

# for 迴圈

``````for (a =[3:5]) {
echo(a);
}
``````

``````sum = 0;
for (a =[3:5]) {
sum = sum + a;
echo(sum);
}
echo(sum);
``````

``````module forLoop(range, value) {
if(range[0] <= range[1]) {
sum = value + range[0];
echo(sum);
forLoop([range[0] + 1, range[1]], value);
}
}

sum = 0;
forLoop([3, 5], sum);
echo(sum);
``````

# 2D 模組

`text` 參數沒有問題，就是你要指定的文字，不好打出來的特殊字元，也可以使用 Unicode 碼指定，例如：

``````text("\u20AC 10 \u263A");
``````

`size` 參數預設是 10，單位是 mm，至於 `font` 則是字 型名稱，如果你要能建立中文，第一要讓 .scad 檔案是 UTF-8 編碼，第二是要指定中文字型，例如，來個「標楷體」的「春」字：

``````text("春", font = "標楷體");
``````

# extrude

``````linear_extrude(10) text("春", font = "標楷體");
``````

# 轉換

``````translate([-5, -5, -5])
linear_extrude(10)
text("春", font = "標楷體");
``````

``````rotate([90, 0, 0])
translate([-5, -5, -5])
linear_extrude(10)
text("春", font = "標楷體");
``````