Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. // (c) Blam 2011
  2. //
  3. //  Documentation
  4. //  axScriptX
  5. //
  6. //  Hello World Example
  7.  
  8. //This defines our entry point (the double tilde).
  9. //A single tilde defines a function.
  10. //No tilde calls a function.
  11. ~~(main: args |
  12.     (
  13.         (test) //call our function 'test'
  14.         (set "a" (str2num (read "Value of a: "))) //a = (double)input
  15.         (-debug "a") //prints out a global var called a and it's value.
  16.         (set "Result" (add $a 40)) //result = a + 40
  17.         (set "Result" (square $Result)) //Square it.
  18.         (print "(a + 40)^2 = {0}" $Result) //print out our sum.
  19.     )
  20. )
  21.  
  22. //This is a custom function, it simply prints a string.
  23. ~(test: (print "Hello World!"))
  24.  
  25. //This is a custom function that uses local variables (parameters count as local variables).
  26. //Local variables are accessed via &name instead of the global $name.
  27. //lset is how we set local variables.
  28. //setting the local return variable sets what we return.
  29. ~(square: num1 | (lset "return" (mult &num1 &num1)))
  30.  
  31. // Output with a input as -30.23
  32. //
  33. // Hello World!
  34. // Value of a: -30.23
  35. // [-debug] "a" = -30.23
  36. // (a + 40)^2 = 95.4529
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement