Implement PRGNAME$
This commit is contained in:
@@ -2334,7 +2334,7 @@ class Exec : Code
|
||||
}
|
||||
wstring content;
|
||||
if (vm.petitcomputer.project.loadFile(file.project, "TXT", file.name, content))
|
||||
vm.petitcomputer.program.slot[slot].load(content);
|
||||
vm.petitcomputer.program.slot[slot].load(file.name, content);
|
||||
else
|
||||
throw new LoadFailed();//TODO:DIALOG?
|
||||
}
|
||||
|
||||
@@ -2280,7 +2280,7 @@ class BuiltinFunction
|
||||
//not exist
|
||||
return;
|
||||
}
|
||||
p.program.slot[lot].load(txt);
|
||||
p.program.slot[lot].load(filename, txt);
|
||||
return;
|
||||
}
|
||||
if(resname.indexOf("GRP") == 0)
|
||||
@@ -3211,6 +3211,14 @@ class BuiltinFunction
|
||||
import otya.smilebasic.program;
|
||||
return p.program.size(slot, cast(SizeType)type);
|
||||
}
|
||||
static wstring PRGNAME(PetitComputer p)
|
||||
{
|
||||
return p.program.name(p.vm.currentSlotNumber);
|
||||
}
|
||||
static wstring PRGNAME(PetitComputer p, int slot)
|
||||
{
|
||||
return p.program.name(slot);
|
||||
}
|
||||
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
||||
static BuiltinFunctions[wstring] builtinFunctions;
|
||||
static wstring getBasicName(BFD)(const wstring def)
|
||||
|
||||
@@ -1093,7 +1093,7 @@ class PetitComputer
|
||||
nodirectmode = true;
|
||||
if (nodirectmode)
|
||||
{
|
||||
program.slot[0].load(readText(inputfile).to!wstring);
|
||||
program.slot[0].load(inputfile.to!wstring, readText(inputfile).to!wstring);
|
||||
runSlot(0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -169,16 +169,18 @@ enum SizeType
|
||||
|
||||
struct Slot
|
||||
{
|
||||
DList!wstring program;
|
||||
DList!wstring.Range range;
|
||||
private DList!wstring program;
|
||||
private DList!wstring.Range range;
|
||||
wstring name;
|
||||
void init()
|
||||
{
|
||||
program = make!(DList!wstring)(["\n"w]);
|
||||
range = program[];
|
||||
}
|
||||
|
||||
void load(wstring data)
|
||||
void load(wstring filename, wstring data)
|
||||
{
|
||||
name = filename;
|
||||
program.clear();
|
||||
foreach(l; splitter(data, "\n"))
|
||||
{
|
||||
@@ -324,11 +326,11 @@ struct Slot
|
||||
switch(type)
|
||||
{
|
||||
case SizeType.Line:
|
||||
return program[].walkLength;
|
||||
return cast(int)program[].walkLength;
|
||||
case SizeType.Char:
|
||||
return program[].map!(x => x.length).sum;
|
||||
return cast(int)program[].map!(x => x.length).sum;
|
||||
case SizeType.FreeChar:
|
||||
return (memorySize - program[].map!(x => x.length).sum).max(0);
|
||||
return cast(int)(memorySize - program[].map!(x => x.length).sum).max(0);
|
||||
default:
|
||||
throw new OutOfRange("PRGSIZE", 2);
|
||||
}
|
||||
@@ -383,4 +385,8 @@ class Program
|
||||
{
|
||||
return this.slot[slot].size(st);
|
||||
}
|
||||
wstring name(int slot)
|
||||
{
|
||||
return this.slot[slot].name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user