Skip to content

Latest commit

 

History

History
115 lines (76 loc) · 1.27 KB

TUTORIAL.md

File metadata and controls

115 lines (76 loc) · 1.27 KB

Project 1 - return an error code

  1. Create a file named first.bts

  2. Type in:

exit 3
  1. Compile and run:
bts run first.bts
  1. Check that the exit code was indeed 3:
echo $?

Project 2 - hello world

  1. Create a file named hello.bts

  2. Type in:

const hi = "Hello, World!", 10
write(hi)
  1. Compile and run:
bts run hello.bts
  1. The output should be:
"Hello, World!"

Project 3 - compile, run and clean

  1. Compile hello.bts from project 2:
bts build hello.bts
  1. Observe that the resulting executable is tiny:
bts size hello.bts
  1. Run it:
./hello
  1. Clean up by removing all the generated files:
bts clean

Project 4 - run as a script

  1. Add this at the top of hello.bts:
#!/usr/bin/bts
  1. Make it executable:
chmod +x hello.bts
  1. Run it as a script:
./hello.bts

Project 5 - loop

  1. Create loop.bts
  2. Type in:
const hi = "Hello there", 10

fun main
  loop 7
    print(hi)
  end
end

"Hello there", 10 is the same as "Hello there\n" since '\n' has ASCII value 10.