invoke function
invoke — corresponds to WML's
Implementation
dynamic invoke(String instance, String method,
{dynamic params, String? result}) {
final ds = _currentRegistry?.find(instance);
if (ds == null) return null;
dynamic ret;
switch (method.toLowerCase()) {
case 'first':
ds.first();
break;
case 'next':
ds.next();
break;
case 'prior':
ds.prior();
break;
case 'last':
ds.last();
break;
case 'edit':
ds.edit();
break;
case 'post':
ds.post();
break;
case 'insert':
ds.insert();
break;
case 'append':
ds.append();
break;
case 'cancel':
ds.cancel();
break;
case 'delete':
ds.delete();
break;
case 'disablecontrols':
ds.disableControls();
break;
case 'enablecontrols':
ds.enableControls();
break;
// ??? beginwalk/endwalk were separate methods in the original code
// (data_db2.dart's TDataSet has beginWalk/endWalk; their exact
// semantics are unclear — the upstream implementation wasn't
// available this time). Guessing it means "start/end a traversal
// pass", which in effect is close to disableControls/enableControls
// (suspend event broadcasting). Mapped to those two for now; revisit
// here if the semantics turn out to be more than that.
case 'beginwalk':
ds.disableControls();
break;
case 'endwalk':
ds.enableControls();
break;
case 'getbookmark':
ret = ds.getBookmark();
break;
case 'gotobookmark':
// @@@ In the full version, TBookmark is a Uint8List (4-byte index);
// @@@ kept compatible with old callers that pass an int
// @@@ (converted to the equivalent bookmark)
if (params is Uint8List) {
ds.gotoBookmark(params);
} else {
final idx = (params is int) ? params : int.tryParse("$params") ?? 0;
final bd = ByteData(4);
bd.setInt32(0, idx, Endian.little);
ds.gotoBookmark(bd.buffer.asUint8List());
}
break;
case 'freebookmark':
break; // no need to free (Dart GC)
default:
break;
}
if (result != null && result.isNotEmpty) {
_currentEvaluator?.setVar(result, ret);
}
return ret;
}