I must be asking the wrong questions,
as Lady Google is currently not giving me the hints I am hoping for…
I hope to construct a little code piece in init.coffee that needs to use a look-up table.
The idea is to use an external CSON file for that.
Could someone please show me what to do to include the CSON file into the coffeescript code. A web search term would help too. I assume it is not needed to include external dependency as Atom already uses CSON files for their own internal configurations.
It is a trivialized example, but it is proof on concept for me. Coding I write for PLCs uses sequence numbers (integers). It happens regularly that I have to “move” stuff around. This will help with exchanging one number (or even a string word) from one to another.
The next step is to replace _string with the text buffer or use scan from Atom’s API.
I have not considered this before as…
a) The text manipulation tasks needed are very variable… depending on the PLC project at hand.
b) I am still feeling my way through what can be done.
c) I am still a bit apprehensive in creating a project. not claiming any logic to that
Granted it does not invalidate your suggestion as my goals can be achieved within (an unpublished) project.
I am not a fan of JSON. In this case it would not matter though as the dictionary is very straight forward. A valuable suggestion you have made.
Thank you for taking the time to make your contribution.
The Coffeescript works when leaving out the const.
atom.commands.add 'atom-text-editor', 'test command', ->
_list = require('dict.json') # no 'const' this is not the real file path
_string = "1 5 7 2 90 4 2"
console.log _string.replace /(\w+)/g, (_get) ->
x = _get
for _key, _value of _list
x = _value if _get == _key
_get = x
Many thanks for voicing the pros of using season. Your notes are important to me.
Using the JSON file is more in line with the needs of current task. It will be configure once, read once and use once per task.
If the task was morphed to more than a code piece; into a project, the season add-in becomes of advantage. It is especially the error checking that would make it attractive. Thereafter comes the ability to write values to the CSON file from some user input.
Bottom line… I am using the JSON file now, but is thankful for knowing what to do with the CSON file when the next phase comes up.