Re: Screenshot of app status
Posted: Mon Aug 31, 2020 5:23 pm
MicheleANE wrote:it keeps telling me that it cannot infer base path or there is no such file to load
The methods do work correctly, but because Ruby is embedded inside FlowStone, they don't know where to search for the files.
Firstly, I'll disregard "require_relative" - it is mostly intended for use within the code of libraries so that a "parent" library file can discover any "child" library files ("cannot infer base path" is because the Ruby code is running inside FlowStone, so technically speaking there is no "parent" Ruby file).
When "require" is called, it searches all of the folders listed in an Array found in the global variable $LOAD_PATH. By default, this only includes a few folders from the FlowStone "Program Files" installation - which is not a very useful place to keep our libraries! Thankfully, the contents of $LOAD_PATH can be modified (take care that you only ever add new items to the Array, as the default folders are necessary for FlowStone to load some of its internal tools).
The code to modify the $LOAD_PATH looks something like this...
Code: Select all
# Use single-quoted Strings to allow literal back-slashes in paths.
load_folder = 'X:\foo\bar\baz'
# Take care to add each folder only once.
unless $LOAD_PATH.include?(load_folder)
# "unshift" puts the new folder at the beginning; i.e. first searched.
$LOAD_PATH.unshift(load_folder)
end
# Now use require as normal.
require "the_library"
If you are installing your code on multiple PCs, a useful variation is to use the "schematicLocation" method to find the folder containing the FlowStone file or exported EXE. You can then store the executable and all of its Ruby dependencies within the same folder (or local sub-folders), which may make distribution/deletion easier...
Code: Select all
load_folder = schematicLocation[:folder]