Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleUse +FROM URL to import a custom version of the file reader component for this tutorial

This component generates some test files to make it easier to learn how to make a custom file reader.

You can useCreate component +FROM URL to import the component.

Copy paste the URL from here:

Code Block
git@bitbucket.org:interfaceware/file_tutorial.git

...

Expand
titleLet's extract the filename using FILfilename() from the FIL Library, so we can look at it:

Change the matching to add in two lines so we can see the filenames we need to filter on.

Code Block
languagelua
function MatchFile(FileName)
   local JustFileName = FILfilename(FileName)
   trace(JustFileName)
   return true
end

These are the concepts we have used:

Expand
titleEdit MatchRules.lua to extract the prefixes from the custom fields

Create a second function, APPidList, to extract the ClientList prefixes from the custom fields and update MatchFile to call APPidList.

You can replace the contents of the MatchRules.lua file with this new code:

Code Block
languagelua
function APPidList()
   local IdList = component.fields()["ClientList"]
   return IdList
end

function MatchFile(FileName)
   local IdList = APPidList()
   trace(IdList)
   local JustFileName = FILfilename(FileName)
   trace(JustFileName)
   return true
end

Concepts used:

Expand
titleBreak the comma delimited string into a list to get each prefix Id

We can quickly do this by adding one line to AppidList after line 2:

Code Block
languagelua
IdList = IdList:split(",")

You should see something like:

Concepts used:

Expand
titleMake a matching function which takes the prefix and sees if the filename starts with it

Create a third function, APPmatchPrefix, to determine if the filename matches the prefix. You can copy the code below:

Code Block
languagelua
function APPmatchPrefix(Prefix, FileName)
   local Part = FileName:sub(1, #Prefix)
   trace(Part, Prefix)
   return (Part == Prefix)
end

See the screenshot below and add a line to MatchFile to call and invoke AppmatchPrefix.

Concepts used:

...

There is no limit to how you can streamline the usage of a custom component - if that helps address a bottleneck, then it is well worth it.  

...