misc: remove extra_data function

This commit is contained in:
Brendan Hagan
2022-07-14 17:33:22 -04:00
parent 4f7fa585f7
commit 52a918be39
3 changed files with 2 additions and 51 deletions
-27
View File
@@ -1,27 +0,0 @@
Function: extra_data
DOC_MSE_VERSION: since 2.2.0
--Usage--
> extra_data("field_name")
Access the value of extra card fields.
Due to lazy initialization of stylesheet specific Extra Card Fields they are not exposed directly from the card using `card.field_name` syntax.
As a workaround this function returns the Value of the specified field name for the active card using an access pattern that supports late resolution of the value for the active stylesheet.
--Parameters--
! Parameter Type Description
| @input@ [[type:string]] Field name, with or without underscores.
--Examples--
>extra card field:
> ...
> name: my first extra field
>
>extra card field:
> ...
> name: my second extra field
> script:
>> space_to_comma(extra_data("my first extra field")) + "!"
+1 -2
View File
@@ -65,8 +65,7 @@ These functions are built into the program, other [[type:function]]s can be defi
| [[fun:english_plural|english_singular]] Find the singular of a word, @"cards" -> "card"@.
| [[fun:process_english_hints]] Process the hints left by english_ functions in a keyword's reminder text.
! Fields and values <<<
| [[fun:extra_data]] Access the value of extra card fields.
! Fields and values <<<
| [[fun:combined_editor|forward_editor]] Use one field to edit another.
| [[fun:combined_editor]] Use one field to edit multiple others.
| [[fun:primary_choice]] Return the top level choice chosen from a choice field.
+1 -22
View File
@@ -382,26 +382,6 @@ SCRIPT_FUNCTION(count_chosen) {
SCRIPT_RETURN(count);
}
}
}
// ----------------------------------------------------------------------------- : Extra Card Fields
SCRIPT_FUNCTION(extra_data) {
SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(CardP, card);
SCRIPT_PARAM_C(StyleSheetP, stylesheet);
// Transform input to standard field name syntax.
// Other functions are doing lookups for ValuePs, which I assume is doing some of this automatically.
String canonical_field_name = canonical_name_form(input);
FOR_EACH(valueP, card->extraDataFor(*stylesheet)) {
if (valueP->fieldP->name == canonical_field_name) {
SCRIPT_RETURN(valueP);
}
}
return delay_error(ScriptErrorNoMember("extra_data()", input));
}
// ----------------------------------------------------------------------------- : Init
@@ -415,6 +395,5 @@ void init_script_editor_functions(Context& ctx) {
ctx.setVariable(_("require_choice"), script_require_choice);
ctx.setVariable(_("exclusive_choice"), script_exclusive_choice);
ctx.setVariable(_("require_exclusive_choice"), script_require_exclusive_choice);
ctx.setVariable(_("remove_choice"), script_remove_choice);
ctx.setVariable(_("extra_data"), script_extra_data);
ctx.setVariable(_("remove_choice"), script_remove_choice);
}