octascript: check for undeclared global variables and error appropriately + fix many cases

The current approach uses a whitelist of allowed global variables. Such
whitelist will not be required when the standard library is redesigned, it's
there only temporarily.