@@ -256,77 +256,71 @@ static bool evaluate_stringref(MCExecPoint &ep, MCExpression *p_expr, uint16_t p
256256 return true ;
257257}
258258
259- Exec_stat MCAsk::exec (class MCExecPoint & ep )
259+ void MCAsk::exec_ctxt (class MCExecContext & ctxt )
260260{
261261 Exec_errors t_error = EE_UNDEFINED;
262-
263- MCExecContext ctxt (ep, it);
264-
265- MCAutoStringRef t_title;
266- if (!evaluate_stringref (ep, title, EE_ANSWER_BADTITLE, line, pos, &t_title))
267- return ES_ERROR;
268-
262+ ctxt . SetIt (it);
263+
264+ MCAutoStringRef t_title;
265+ if (!ctxt . EvalOptionalExprAsStringRef (title, kMCEmptyString , EE_ANSWER_BADTITLE, &t_title))
266+ return ;
267+
269268 switch (mode)
270269 {
271- case AT_PASSWORD:
272- case AT_CLEAR:
273- {
274- MCAutoStringRef t_prompt, t_answer;
275- if (!evaluate_stringref (ep, password . prompt, EE_ASK_BADREPLY, line, pos, &t_prompt))
276- return ES_ERROR;
277- if (!evaluate_stringref (ep, password . answer, EE_ASK_BADREPLY, line, pos, &t_answer))
278- return ES_ERROR;
279- MCDialogExecAskPassword (ctxt, mode == AT_CLEAR, *t_prompt, *t_answer, password . hint, *t_title, sheet == True);
270+ case AT_PASSWORD:
271+ case AT_CLEAR:
272+ {
273+ MCAutoStringRef t_prompt, t_answer;
274+ if (!ctxt . EvalOptionalExprAsStringRef (password . prompt, kMCEmptyString , EE_ASK_BADREPLY, &t_prompt))
275+ return ;
276+ if (!ctxt . EvalOptionalExprAsStringRef (password . answer, kMCEmptyString , EE_ASK_BADREPLY, &t_answer))
277+ return ;
278+ MCDialogExecAskPassword (ctxt, mode == AT_CLEAR, *t_prompt, *t_answer, password . hint, *t_title, sheet == True);
279+ }
280+ break ;
281+
282+ case AT_FILE:
283+ {
284+ MCAutoStringRef t_prompt, t_initial, t_filter;
285+ MCAutoStringRefArray t_types;
286+
287+ if (!ctxt . EvalOptionalExprAsStringRef (file.prompt , kMCEmptyString , EE_ANSWER_BADQUESTION, &t_prompt))
288+ return ;
289+ if (!ctxt . EvalOptionalExprAsStringRef (file.initial , kMCEmptyString , EE_ANSWER_BADQUESTION, &t_initial))
290+ return ;
291+ if (!ctxt . EvalOptionalExprAsStringRef (file.filter , kMCEmptyString , EE_ANSWER_BADQUESTION, &t_filter))
292+ return ;
293+
294+ if (file . type_count > 0 )
295+ {
296+ /* UNCHECKED */ t_types.Extend (file.type_count );
297+ for (uindex_t i = 0 ; i < file.type_count ; i++)
298+ {
299+ if (!ctxt . EvalOptionalExprAsStringRef (file.types [i], kMCEmptyString , EE_ANSWER_BADQUESTION, t_types[i]))
300+ return ;
301+ }
302+ }
303+
304+ if (t_types.Count () > 0 )
305+ MCDialogExecAskFileWithTypes (ctxt, *t_prompt, *t_initial, *t_types, t_types . Count (), *t_title, sheet == True);
306+ else if (*t_filter != nil)
307+ MCDialogExecAskFileWithFilter (ctxt, *t_prompt, *t_initial, *t_filter, *t_title, sheet == True);
308+ else
309+ MCDialogExecAskFile (ctxt, *t_prompt, *t_initial, *t_title, sheet == True);
310+ }
311+ break ;
312+
313+ default :
314+ {
315+ MCAutoStringRef t_prompt, t_answer;
316+ if (!ctxt . EvalOptionalExprAsStringRef (question . prompt, kMCEmptyString , EE_ASK_BADREPLY, &t_prompt))
317+ return ;
318+ if (!ctxt . EvalOptionalExprAsStringRef (question . answer, kMCEmptyString , EE_ASK_BADREPLY, &t_answer))
319+ return ;
320+ MCDialogExecAskQuestion (ctxt, mode, *t_prompt, *t_answer, question . hint, *t_title, sheet == True);
321+ }
322+ break ;
280323 }
281- break ;
282-
283- case AT_FILE:
284- {
285- MCAutoStringRef t_prompt, t_initial, t_filter;
286- MCAutoStringRefArray t_types;
287-
288- if (!evaluate_stringref (ep, file.prompt , EE_ANSWER_BADQUESTION, line, pos, &t_prompt))
289- return ES_ERROR;
290- if (!evaluate_stringref (ep, file.initial , EE_ANSWER_BADQUESTION, line, pos, &t_initial))
291- return ES_ERROR;
292- if (!evaluate_stringref (ep, file.filter , EE_ANSWER_BADQUESTION, line, pos, &t_filter))
293- return ES_ERROR;
294-
295- if (file . type_count > 0 )
296- {
297- /* UNCHECKED */ t_types.Extend (file.type_count );
298- for (uindex_t i = 0 ; i < file.type_count ; i++)
299- {
300- if (!evaluate_stringref (ep, file.types [i], EE_ANSWER_BADQUESTION, line, pos, t_types[i]))
301- return ES_ERROR;
302- }
303- }
304-
305- if (t_types.Count () > 0 )
306- MCDialogExecAskFileWithTypes (ctxt, *t_prompt, *t_initial, *t_types, t_types . Count (), *t_title, sheet == True);
307- else if (*t_filter != nil)
308- MCDialogExecAskFileWithFilter (ctxt, *t_prompt, *t_initial, *t_filter, *t_title, sheet == True);
309- else
310- MCDialogExecAskFile (ctxt, *t_prompt, *t_initial, *t_title, sheet == True);
311- }
312- break ;
313-
314- default :
315- {
316- MCAutoStringRef t_prompt, t_answer;
317- if (!evaluate_stringref (ep, question . prompt, EE_ASK_BADREPLY, line, pos, &t_prompt))
318- return ES_ERROR;
319- if (!evaluate_stringref (ep, question . answer, EE_ASK_BADREPLY, line, pos, &t_answer))
320- return ES_ERROR;
321- MCDialogExecAskQuestion (ctxt, mode, *t_prompt, *t_answer, question . hint, *t_title, sheet == True);
322- }
323- break ;
324- }
325-
326- if (!ctxt . HasError ())
327- return ES_NORMAL;
328-
329- return ctxt . Catch (line, pos);
330324}
331325
332326#ifdef /* MCAsk::exec_question */ LEGACY_EXEC
0 commit comments