How to share variables with Yab lib?
#4
(10-08-2024, 01:18 AM)clasqm Wrote:
(10-07-2024, 07:42 PM)PurpleStudio Wrote: I've completed 1 subroutine, saved it as 'routineExample.yab' and then used "EXPORT SUB routineEXAMPLE()" and then in my main program I call it with "IMPORT routineExample" however, the imported subroutine isn't sharing variables I've declared in my main program & which I rely on in routineEXAMPLE().

Is it possible to do this?

Your global variables should definitely be available. Double-check that you've used them in the same case. Variables are case-sensitive.

local variables need to be passed to the library the same way you'd pass them between subroutines.

At the moment, none of the variables in my main program are declared 'local' and from YAB Documentation, unless explicitly stated, all variables are declared global.

I checked my code again. variables are character-for-character, taking case sensitivity into account. Still nothing. I tried just pasting the subroutine from the file I want to import directly in my main program, and it works just fine, but as soon as I remove it and use the import file$ it stops working.

I wonder if it is because of WHERE I am importing the file. Right now, it's at the very top of my main program below #! /bin/yab. I wonder if I paste that import at the bottom after all variables are declared, it would work...

I really don't want to have to pass variables via subroutine arguments (example: routineExample(num1, num2, string1$, string2$)) because then I can only "RETURN" one value and I would have several things to return (such as a msg$).
Reply


Messages In This Thread
RE: How to share variables with Yab lib? - by PurpleStudio - 10-08-2024, 08:12 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)
Free Web Hosting