Merge pull request #3064 from scratchcoder27/master

Added Variable Substitution support to `first` and `last` stmts in AUTOCAL
This commit is contained in:
HbmMods 2026-07-27 13:02:47 +02:00 committed by GitHub
commit a34ca12047
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,7 +93,7 @@ public class ParseMSES1Ext1 extends ParseMSES1 {
if(lower.startsWith("first ")) {
if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR;
try {
int length = Integer.parseInt(line.substring(6));
int length = Integer.parseInt(substitute(ctx, line.substring(6), true));
int max = ctx.readBuffer().length();
if(length > max) length = max;
ctx.writeBuffer(ctx.readBuffer().substring(0, length));
@ -105,7 +105,7 @@ public class ParseMSES1Ext1 extends ParseMSES1 {
if(lower.startsWith("last ")) {
if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR;
try {
int length = Integer.parseInt(line.substring(5));
int length = Integer.parseInt(substitute(ctx, line.substring(5), true));
int max = ctx.readBuffer().length();
if(length > max) length = max;
ctx.writeBuffer(ctx.readBuffer().substring(max - length, max));