Need Clarification on JSON String Formatting Error
Posted: June 30th, 2025, 12:39 pm
Dear Team,
I hope this message finds you well.
I am currently using the following lines of code, but I encountered the error.
function numeric ViewQuestionnaire(string dictionary_name="CEN2000")
setfile(CEN2000, "..\103 - Data\Census_data.csdb");
string cen2000_directory = "C:\214 - YouTube CSPro - syntime\100 - SyncTimeApp" ;
string cen2000_form_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.fmf");
string cen2000_qsf_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.ent.qsf");
string questionnaireViewInput =
maketext("{ \"dictionary\": %s, \"forms\": %s, \"questionText\": %s, \"case\": %s }",
CS.Dictionary.getDictionary(name := "CEN2000"),
CS.Application.getFormFile(path := cen2000_form_path),
CS.Application.getQuestionText(path := cen2000_qsf_path),
CS.Data.getCase(name := "CEN2000", key :="010101301520130191"));
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
inputData := @object questionnaireViewInput);
end;
ERROR(ViewQuestionnaire, 305): 'dictionary\"' is not a declared variable or is a misspelled dictionary entry
However, when I removed the backslash (\), the code executed successfully.
function numeric ViewQuestionnaire(string dictionary_name="CEN2000")
setfile(CEN2000, "..\103 - Data\Census_data.csdb");
string cen2000_directory = "C:\214 - YouTube CSPro - syntime\100 - SyncTimeApp" ;
string cen2000_form_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.fmf");
string cen2000_qsf_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.ent.qsf");
string questionnaireViewInput =
maketext('{"dictionary": %s, "forms": %s, "questionText": %s, "case": %s}',
CS.Dictionary.getDictionary(name := "CEN2000"),
CS.Application.getFormFile(path := cen2000_form_path),
CS.Application.getQuestionText(path := cen2000_qsf_path),
CS.Data.getCase(name := "CEN2000", key :="010101301520130191"));
// // pass this input to the questionnaire view
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
inputData := @object questionnaireViewInput);
end;
Could you please confirm if this is the correct approach, or let me know if there is an issue with my code?
Thank you for your support.
Best regards,
a.
I hope this message finds you well.
I am currently using the following lines of code, but I encountered the error.
function numeric ViewQuestionnaire(string dictionary_name="CEN2000")
setfile(CEN2000, "..\103 - Data\Census_data.csdb");
string cen2000_directory = "C:\214 - YouTube CSPro - syntime\100 - SyncTimeApp" ;
string cen2000_form_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.fmf");
string cen2000_qsf_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.ent.qsf");
string questionnaireViewInput =
maketext("{ \"dictionary\": %s, \"forms\": %s, \"questionText\": %s, \"case\": %s }",
CS.Dictionary.getDictionary(name := "CEN2000"),
CS.Application.getFormFile(path := cen2000_form_path),
CS.Application.getQuestionText(path := cen2000_qsf_path),
CS.Data.getCase(name := "CEN2000", key :="010101301520130191"));
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
inputData := @object questionnaireViewInput);
end;
ERROR(ViewQuestionnaire, 305): 'dictionary\"' is not a declared variable or is a misspelled dictionary entry
However, when I removed the backslash (\), the code executed successfully.
function numeric ViewQuestionnaire(string dictionary_name="CEN2000")
setfile(CEN2000, "..\103 - Data\Census_data.csdb");
string cen2000_directory = "C:\214 - YouTube CSPro - syntime\100 - SyncTimeApp" ;
string cen2000_form_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.fmf");
string cen2000_qsf_path = Path.concat(cen2000_directory, "102 - Popstan Census", "Census Data Entry.ent.qsf");
string questionnaireViewInput =
maketext('{"dictionary": %s, "forms": %s, "questionText": %s, "case": %s}',
CS.Dictionary.getDictionary(name := "CEN2000"),
CS.Application.getFormFile(path := cen2000_form_path),
CS.Application.getQuestionText(path := cen2000_qsf_path),
CS.Data.getCase(name := "CEN2000", key :="010101301520130191"));
// // pass this input to the questionnaire view
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
inputData := @object questionnaireViewInput);
end;
Could you please confirm if this is the correct approach, or let me know if there is an issue with my code?
Thank you for your support.
Best regards,
a.