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 ~ ")");
|
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
|
class StringTooLong : SmileBasicError
|
||||||
{
|
{
|
||||||
this()
|
this()
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
module otya.smilebasic.program;
|
module otya.smilebasic.program;
|
||||||
|
import otya.smilebasic.error;
|
||||||
import std.range;
|
import std.range;
|
||||||
import std.container;
|
import std.container;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
import std.algorithm;
|
||||||
|
|
||||||
struct Slot
|
struct Slot
|
||||||
{
|
{
|
||||||
@@ -112,6 +114,7 @@ struct Slot
|
|||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
Slot[] slot;
|
Slot[] slot;
|
||||||
|
bool PRGEDITused;
|
||||||
int currentSlot;
|
int currentSlot;
|
||||||
int slotSize = 4;
|
int slotSize = 4;
|
||||||
this()
|
this()
|
||||||
@@ -124,15 +127,20 @@ class Program
|
|||||||
}
|
}
|
||||||
void edit(int slot, int line)
|
void edit(int slot, int line)
|
||||||
{
|
{
|
||||||
|
PRGEDITused = true;
|
||||||
this.currentSlot = slot;
|
this.currentSlot = slot;
|
||||||
this.slot[slot].currentLine = line;
|
this.slot[slot].currentLine = line;
|
||||||
}
|
}
|
||||||
wstring get()
|
wstring get()
|
||||||
{
|
{
|
||||||
|
if (!PRGEDITused)
|
||||||
|
throw new UsePRGEDITBeforeAnyPRGFunction("PRGGET$");
|
||||||
return this.slot[currentSlot].get;
|
return this.slot[currentSlot].get;
|
||||||
}
|
}
|
||||||
void set(wstring v)
|
void set(wstring v)
|
||||||
{
|
{
|
||||||
|
if (!PRGEDITused)
|
||||||
|
throw new UsePRGEDITBeforeAnyPRGFunction("PRGSET");
|
||||||
this.slot[currentSlot].set = v;
|
this.slot[currentSlot].set = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user