Add Use PRGEDIT before any PRG function
This commit is contained in:
@@ -191,6 +191,14 @@ class SubscriptOutOfRange : SmileBasicError
|
||||
super("Subscript out of range(" ~ func ~ ":" ~ arg.to!string ~ ")");
|
||||
}
|
||||
}
|
||||
class UsePRGEDITBeforeAnyPRGFunction : SmileBasicError
|
||||
{
|
||||
this(string func)
|
||||
{
|
||||
this.errnum = 38;
|
||||
super("Use PRGEDIT before any PRG function(" ~ func ~ ")");
|
||||
}
|
||||
}
|
||||
class StringTooLong : SmileBasicError
|
||||
{
|
||||
this()
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
module otya.smilebasic.program;
|
||||
import otya.smilebasic.error;
|
||||
import std.range;
|
||||
import std.container;
|
||||
import std.algorithm;
|
||||
import std.algorithm;
|
||||
|
||||
struct Slot
|
||||
{
|
||||
@@ -112,6 +114,7 @@ struct Slot
|
||||
class Program
|
||||
{
|
||||
Slot[] slot;
|
||||
bool PRGEDITused;
|
||||
int currentSlot;
|
||||
int slotSize = 4;
|
||||
this()
|
||||
@@ -124,15 +127,20 @@ class Program
|
||||
}
|
||||
void edit(int slot, int line)
|
||||
{
|
||||
PRGEDITused = true;
|
||||
this.currentSlot = slot;
|
||||
this.slot[slot].currentLine = line;
|
||||
}
|
||||
wstring get()
|
||||
{
|
||||
if (!PRGEDITused)
|
||||
throw new UsePRGEDITBeforeAnyPRGFunction("PRGGET$");
|
||||
return this.slot[currentSlot].get;
|
||||
}
|
||||
void set(wstring v)
|
||||
{
|
||||
if (!PRGEDITused)
|
||||
throw new UsePRGEDITBeforeAnyPRGFunction("PRGSET");
|
||||
this.slot[currentSlot].set = v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user