HEX$に桁数指定できるようにした
This commit is contained in:
@@ -32,6 +32,7 @@ ASSERT__ VAL("aa")==0, "VAL"
|
|||||||
|
|
||||||
ASSERT__ RAD(180)==PI(), "RAD"
|
ASSERT__ RAD(180)==PI(), "RAD"
|
||||||
ASSERT__ DEG(RAD(180)), "DEG"
|
ASSERT__ DEG(RAD(180)), "DEG"
|
||||||
|
ASSERT__ HEX$(65535, 8)=="0000FFFF", "HEX$"
|
||||||
ASSERT__ SUBST$("0123456789",0,"B")=="B","SUBST$"
|
ASSERT__ SUBST$("0123456789",0,"B")=="B","SUBST$"
|
||||||
ASSERT__ SUBST$("0123456789",0,4,"B")=="B456789","SUBST$"
|
ASSERT__ SUBST$("0123456789",0,4,"B")=="B456789","SUBST$"
|
||||||
ASSERT__ SUBST$("",0,4,"B")=="B","SUBST$"
|
ASSERT__ SUBST$("",0,4,"B")=="B","SUBST$"
|
||||||
|
|||||||
@@ -365,11 +365,26 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
return val.to!wstring;
|
return val.to!wstring;
|
||||||
}
|
}
|
||||||
static wstring HEX(int val)
|
static wstring HEX(int val, DefaultValue!(int, false) digits)
|
||||||
|
{
|
||||||
|
import std.format;
|
||||||
|
if(digits.isDefault)
|
||||||
{
|
{
|
||||||
//ひどい
|
//ひどい
|
||||||
return val.to!string(16).to!wstring;
|
return val.to!string(16).to!wstring;
|
||||||
}
|
}
|
||||||
|
if(digits > 8)
|
||||||
|
{
|
||||||
|
throw new OutOfRange();
|
||||||
|
}
|
||||||
|
FormatSpec!char f;
|
||||||
|
f.spec = 'X';
|
||||||
|
f.flZero = true;
|
||||||
|
f.width = cast(int)digits;
|
||||||
|
auto w = appender!wstring();
|
||||||
|
formatValue(w, val, f);
|
||||||
|
return cast(immutable)(w.data);
|
||||||
|
}
|
||||||
static void SPSET(PetitComputer p, int id, int defno)
|
static void SPSET(PetitComputer p, int id, int defno)
|
||||||
{
|
{
|
||||||
p.sprite.spset(id, defno);
|
p.sprite.spset(id, defno);
|
||||||
|
|||||||
@@ -64,6 +64,14 @@ class TypeMismatch : SmileBasicError
|
|||||||
super("Type mismatch");
|
super("Type mismatch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class OutOfRange : SmileBasicError
|
||||||
|
{
|
||||||
|
this()
|
||||||
|
{
|
||||||
|
this.errnum = 10;
|
||||||
|
super("Out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
class OutOfDATA : SmileBasicError
|
class OutOfDATA : SmileBasicError
|
||||||
{
|
{
|
||||||
this()
|
this()
|
||||||
|
|||||||
Reference in New Issue
Block a user