Code Examples
Here are some clean examples of BigC v0.5 in action.
1. Hello World
The classic entry point. Demonstrates basic assignment, interpolation, and math.
# hello.big
Name = "BigCoder"
print "Hello, $Name!"
# Math
get 10 5 + & set as {Result}
print "10 + 5 = $Result"
2. Simple Web Server
Using the BigWeb engine to host a basic page.
# web_demo.big
use web
start chapter Home
reply with "<h1>Welcome to BigC Web</h1>"
end chapter
on get "/" run Home
print "Listening on 8080..."
start server at 8080
3. Basic Calculator
Demonstrates user input (take response) and synchronization (wait type export).
# calc.big
print "Enter a number:"
take response
wait type export
Num1 = export
print "Enter another number:"
take response
wait type export
Num2 = export
get Num1 Num2 + & set as {Sum}
print "Sum: $Sum"
4. The Wiki Source (Recursive Example)
This very website is a BigC program! Here is a simplified version of the logic running bigc.ponpyin.org.
# wiki_source.big
use web
# -- PRE-LOAD --
open "pages/home.big" & set as {HomeContent}
# -- RENDERER --
start chapter Render
get markdown HomeContent & set as {Html}
reply with "<html><body>$Html</body></html>"
end chapter
# -- ROUTES --
on get "/" run Render
# -- START --
print "Wiki Server Running..."
start server at 8080