Post Reply 
[question]userRPL, functions or (sub)subprograms and directories
03-29-2017, 05:39 PM
Post: #10
RE: [question]userRPL and functions or (sub)subprograms
(03-29-2017 04:42 PM)pier4r Wrote:  Is it defined in the manuals or is it something that the community discovered and was underdocumented?

It's defined in the 50g Users Guide (English version) on page 21-4, and I believe in other documents as well.

Sometimes sample code can show how things work more clearly than lengthy descriptions:
Code:
%%HP: T(3)A(R)F(.);
DIR
  test
  \<< foobar "root" \->TAG \>>

  foo
  1

  bar
  5

  foobar
  \<< foo bar + \>>

  dir2
  DIR
    test
    \<< foobar "dir2" \->TAG \>>

    foo
    2

    dir3
    DIR
      test
      \<< foobar "dir3" \->TAG \>>

      bar
      100

    END
  END
END

Running "test" in each directory will give different results due to the variables "foo" and "bar" being redefined. Note that neither the function calls nor the variable references need paths -- the O/S simply looks for the named objects and executes the first one it finds with that name in the current search path.

This example shows another important concept to keep in mind: while "test" in dir2 and dir3 is actually running a program (foobar) that resides in a higher level directory, the search path that applies is whichever one was current when you started "test" -- not the path starting from the location of "foobar". The current path always starts at the current directory that the user sets, unless (of course) the program explicitly changes that.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [question]userRPL and functions or (sub)subprograms - DavidM - 03-29-2017 05:39 PM
about DIR END - pier4r - 03-29-2017, 06:15 PM



User(s) browsing this thread: 1 Guest(s)