Hi, sorry I don’t have a working example to show, but hopefully the question itself is generic enough to not need one.
I’m working on a system so that settings can be changed, saved into a file, and automatically loaded.
I want the settings file to only contain text and/or numbers, since these are the only things that can be shared safely between projects or different versions of the same project.
My first draft of this system, which works well, includes this:
[spoiler]To say setting (T - a number):
let S be the content corresponding to an index of T in the Table of Settings;
say S;
Table of Settings Menu [Menus by Dannii Willis]
title (text) text (text) submenu (table-name) rule (rule) hidden-row (truth state)
“Graphics [setting 2]” – -- the graphics toggling rule –
[Other menu entries to change other settings go here, not up to that yet]
Table of Settings [this is the thing that gets saved]
index (number) content (text)
“1” “[the release number]” [release number]
“2” “on” [graphics][/spoiler]
This means the menu has a line saying Graphics on, and after you toggle it the line says Graphics off.
This works well, but I decided that referring to all the settings by number rather than name might lead to problems, so I changed it to the following:
[spoiler]To say setting (T - some text):
let S be the content corresponding to a name of T in the Table of Settings;
say S;
Table of Settings Menu
title (text) text (text) submenu (table-name) rule (rule) hidden-row (truth state)
“Graphics [setting graphic]” – -- the graphics toggling rule –
Table of Settings
name (text) content (text)
“release number” “[the release number]” [release number]
“graphic” “on” [graphics][/spoiler]
This leads to an issue in my text substitution. The story doesn’t compile, saying:
Problem. In the sentence ‘“Graphics [setting of graphic]”’ , I was expecting to read a text, but instead found some text that I couldn’t understand - ‘graphic’.
I searched the documentation for a To say (T - some text) rule but didn’t find anything, and when I put it like that it seems like a strange thing to allow. I would like to do it though, so, is there a good way to put text (as in a string) inside square brackets, which are inside text?
I imagine the way Inform would like me to do this is to make settings a kind or value so I can refer to them that way, but I need to store them as text anyway so that seems excessive.
On the other hand, maybe I should just store it as plain numbers to be more memory/object efficient?