Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Can you pass a parameter to a subroutine?

A topic by Garry Francis created Feb 09, 2020 Views: 101 Replies: 5
Viewing posts 1 to 3
Submitted

Can you pass a parameter to a subroutine, preferably a string, but also an object?

Submitted

For string I have a simple solution:

...
: set_string var = "test_var"  text = "some val" ;
: gosub "my_sub" ;
...
my_sub : subroutine {
    : if (test_var == "some val" ){
        ...
    }
}

Probably for objects it only can be if-elseif-else block in the subroutine.

Submitted

That's what I'm doing at the moment and I think that's the only way you can do it, but it sure would be nice if you could say something like:

: gosub "my_sub" param = "some val";

Then in the subroutine, you can use:

my_sub : subroutine {
   :if (param == "some val") {
      ...
   }
}

Saves a lot of typing and avoids having to declare a global variable just for the subroutine.

Submitted

Agree, it would be cool. But we have what we have)

Submitted

You never know. There are all sorts of undocumented things tucked away in Adventuron.

Host

Not a hidden feature. It's a future feature though.