Template parsing error messages have been added to the status bar.

Сообщения об ошибках:
"The column name %s was not found in the query results" - имя колонки не найдено в результатах запроса.
"The column name  %s is not closed"                     - пропущен закрывающий символ @.
"The column name empty. %s ."                           - Имя не задано. Обычно бывает когда пропущен @.
"Incorrect flag at the %s column."                      - Не верный флаг. Поддерживается пока только "a".

Добавлено экранирование \t, \r
This commit is contained in:
lsv 2026-01-16 10:25:12 +05:00
parent a8ddbc4999
commit 63d0c37478
2 changed files with 31 additions and 10 deletions

View file

@ -366,12 +366,17 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action)
ElementTempl e;
bool isvar=false;
wxString col;
int startvarpos=0;
while (pos<len)
{
c=templ[pos++];
if (c=='\\' && pos<len) {
c=templ[pos++];
if (c=='n') c='\n';
if (c=='t') c='\t';
if (c=='r') c='\r';
e.txt.Append(c);
continue;
}
if (isvar) {
if (c==',') {
@ -379,6 +384,11 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action)
{
//if (c=='n') e.flags.colname=true;
if (c=='a') isalign=true;
else {
wxString msg=wxString::Format(_("Incorrect flag at the %s column."),col);
if (action == 0) wxMessageBox(msg);
return msg;
}
}
}
if (c=='[') {
@ -396,10 +406,16 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action)
}
if (c=='@') {
isvar=false;
if (col.Len()==0) {
wxString msg=wxString::Format(_("The column name empty. %s ."),templ.substr(startvarpos,pos-startvarpos));
if (action == 0) wxMessageBox(msg);
return msg;
}
int idx=colNames.Index(col);
if (idx==wxNOT_FOUND) {
if (action == 0) wxMessageBox(wxString::Format("Not found col name %s in result query.",col));
return wxEmptyString;
wxString msg=wxString::Format(_("The column name %s was not found in the query results."),col);
if (action == 0) wxMessageBox(msg);
return msg;
}
e.column=idx;
tmplvector.push_back(e);
@ -412,6 +428,7 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action)
e.txt.Append(c);
} else {
isvar=true;
startvarpos=pos-1;
tmplvector.push_back(e);
e.txt.Clear();
col.Clear();
@ -420,8 +437,9 @@ wxString ctlSQLResult::GenerateTemplate(wxString &templ,int action)
}
if (isvar )
{
if (action == 0) wxMessageBox(wxString::Format("No close col name %s",col));
return wxEmptyString;
wxString msg=wxString::Format(_("The column name %s is not closed."),col);
if (action == 0) wxMessageBox(msg);
return msg;
}
else
{

View file

@ -2231,17 +2231,20 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
xmenu->Append(MNU_COPY_TABLEHTML, _("Copy table html format"), _("Copy table html format."));
if (body_template.Count()>0) {
//MNU_GENERATE_TEMPLATE
wxMenu *submenu = new wxMenu();
wxMenu *submenu = NULL;
//wxString t="begin @obj_id@ end";
int cnt=0;
for(int i=0;i<body_template.Count();i++) {
wxString s=sqlResult->GenerateTemplate(body_template[i],1);
if (s=="OK")
wxString s=sqlResult->GenerateTemplate(body_template[i],1);
if (s=="OK")
{
cnt++;
submenu->Append(MNU_GENERATESQL+cnt,title_template[i],body_template[i]);
}
if (submenu==NULL) submenu = new wxMenu();
cnt++;
submenu->Append(MNU_GENERATESQL+cnt,title_template[i],body_template[i]);
} else
SetStatusText(s, STATUSPOS_MSGS);
}
if (cnt>0) xmenu->Append(MNU_GENERATESQL,"Generate",submenu);
}
xmenu->AppendSeparator();