Skiylia-Lang / Verboscript

A toy programming language made in python; designed to be close to written english
GNU General Public License v3.0
2 stars 0 forks source link

Branching Statements #12

Open SK1Y101 opened 3 years ago

SK1Y101 commented 3 years ago

If statement

A singular if is the simplest branching statement, and decides whether a chunk of code will be executed or not, depending on some condition.

Python:

if x == 0:
  print("x was zero")

Verboscript:

if x is equal to zero, then do the following:
  show "x" was zero.

Else statement

if the if was not true, then the else is triggered:

Python:

if x == 0:
  print("x was zero")
else:
  print("x was not zero")

Verboscript:

if x is equal to zero, then do the following:
  show "x" was zero.
otherwise, do this:
  show "x" was not zero.
if x is equal to zero, then do the following:
  show "x" was zero.
else, do this:
  show "x" was not zero.

both otherwise and else could be applicable.

SK1Y101 commented 3 years ago

Potential for the if-elif-else block:

Python:

if x == 0:
  print("x was zero")
elif x == 2:
  print("x was two")
elif x == 7:
  print("x was seven")
elif x == 354:
  print("x was three hundred and fifty four")
else:
  print("x was not any of the numbers listed")

Verboscript could instead make use of a modified version of the else command decided above:

if x is equal to zero, then do the following:
  show "x" was zero.
else, if x is equal to two, then do this:
  show "x" was two.
if x is instead equal to seven, then do this:
  show "x" was seven.
alternatively, if x is equal to three hundred and fifty four, then do this:
  show "x" was three hundred and fifty four.
otherwise, do this:
  show "x" was not any of the numbers listed.