diff --git a/SMILEBASIC/SMILEBASIC.visualdproj b/SMILEBASIC/SMILEBASIC.visualdproj index 8481e6a..9519377 100644 --- a/SMILEBASIC/SMILEBASIC.visualdproj +++ b/SMILEBASIC/SMILEBASIC.visualdproj @@ -72,7 +72,7 @@ 0 0 - NDirectMode + 0 0 0 diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 85844bc..75afbf6 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -1381,6 +1381,24 @@ class BuiltinFunction flag.setDefaultValue(0); throw new IllegalFunctionCall("NOTIMPL:LOAD"); } + static void PROJECT(PetitComputer p, wstring name) + { + //DirectMode only + if(p.isRunningDirectMode) + { + if(!p.project.isValidProjectName(name)) + { + throw new IllegalFunctionCall("PROJECT"); + } + p.currentProject = name; + return; + } + throw new CantUseInProgram("PROJECT"); + } + static void PROJECT(PetitComputer p, out wstring name) + { + name = p.currentProject; + } //alias void function(PetitComputer, Value[], Value[]) BuiltinFunc; static BuiltinFunctions[wstring] builtinFunctions; static wstring getBasicName(BFD)(const wstring def) @@ -1872,9 +1890,18 @@ template AddFuncArg(int L, int N, int M, int O, BFD, P...) } else static if(is(P[0] == wstring)) { - enum add = 1; - enum outadd = 0; - const string arg = "arg[" ~ I.to!string ~ "].castString"; + static if(storage & ParameterStorageClass.out_) + { + enum add = 0; + enum outadd = 1; + const string arg = "ret[" ~ O.to!string ~ "].stringValue"; + } + else + { + enum add = 1; + enum outadd = 0; + const string arg = "arg[" ~ I.to!string ~ "].castString"; + } } else static if(is(P[0] == DefaultValue!int)) { @@ -1995,6 +2022,10 @@ template OutArgsInit(BFD, int I = 0, int J = 0) { enum ret2 = "ValueType.Void;"; } + else static if(is(param[I] == wstring)) + { + enum ret2 = "ValueType.String;"; + } else { static assert(false, "invalid type " ~ param[I].stringof); diff --git a/SMILEBASIC/error.d b/SMILEBASIC/error.d index bc4eabe..42730de 100644 --- a/SMILEBASIC/error.d +++ b/SMILEBASIC/error.d @@ -114,4 +114,12 @@ class CantUseFromDirectMode : SmileBasicError super("Can't use from direct mode"); } } +class CantUseInProgram : SmileBasicError +{ + this(wstring func) + { + this.errnum = 44; + super("Can't use in program"); + } +} diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index bd5a59d..187f83c 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -1115,6 +1115,7 @@ class PetitComputer printConsole("OK\n"); } Slot[] slot; + bool isRunningDirectMode = false; void run() { slot = new Slot[5]; @@ -1133,7 +1134,6 @@ class PetitComputer Parser parser; otya.smilebasic.vm.VM vm; bool directMode = false; - bool isRunningDirectMode = false; int oldpc; void runSlot(int lot) {