Implement BIN$
This commit is contained in:
@@ -1350,12 +1350,18 @@ class BuiltinFunction
|
||||
str2[digits - str.length..digits] = str;
|
||||
return str2[0..digits].to!wstring;
|
||||
}
|
||||
/+
|
||||
HEX$(1,0)=>1
|
||||
HEX$(1)=>1
|
||||
HEX$(1,)=>1(???)
|
||||
HEX$(1,2)=>01
|
||||
+/
|
||||
static wstring HEX(int val, DefaultValue!(int, false) digits)
|
||||
{
|
||||
import std.format;
|
||||
if(digits > 8 || digits < 0)
|
||||
{
|
||||
throw new OutOfRange();
|
||||
throw new OutOfRange("HEX$", 2);
|
||||
}
|
||||
FormatSpec!char f;
|
||||
f.spec = 'X';
|
||||
@@ -1365,6 +1371,31 @@ class BuiltinFunction
|
||||
formatValue(w, val, f);
|
||||
return cast(immutable)(w.data);
|
||||
}
|
||||
/+
|
||||
BIN$(1,0)=>1
|
||||
BIN$(1)=>1
|
||||
BIN$(1,)=>Type mismatch(BIN$:2)
|
||||
BIN$(1,2)=>01
|
||||
+/
|
||||
static wstring BIN(int val)
|
||||
{
|
||||
return val.to!wstring(2);
|
||||
}
|
||||
static wstring BIN(int val, int digits)
|
||||
{
|
||||
import std.format;
|
||||
if(digits > 32 || digits < 0)
|
||||
{
|
||||
throw new OutOfRange("BIN$", 2);
|
||||
}
|
||||
FormatSpec!char f;
|
||||
f.spec = 'b';
|
||||
f.flZero = true;
|
||||
f.width = digits;
|
||||
auto w = appender!wstring();
|
||||
formatValue(w, val, f);
|
||||
return cast(immutable)(w.data);
|
||||
}
|
||||
static void SPSET(PetitComputer p, int id, int defno, DefaultValue!(int, false) V, DefaultValue!(int, false) W, DefaultValue!(int, false) H, DefaultValue!(int, false) ATTR)
|
||||
{
|
||||
if(!V.isDefault && !W.isDefault)
|
||||
|
||||
Reference in New Issue
Block a user