|
こみやんまさんのhm.Net.dllで、秀丸マクロの関数を実行するメソッド
Hidemaru.Hm.Macro.Function( System.String functionName , params System.Object[] args ) ;
において、マクロ関数の引数のargsにSystem.Double型の倍精度浮動小数点数を直接指定すると、
エラーメッセージ表示されてそれ以降のHidemaru.Hm.Macro.Function()やHidemaru.Hm.Macro.Eval()などの
メソッドが全て失敗します。
検証コードは次の通りです。
//---------------- StrFloat.dll ----------------
using System ;
using Hidemaru ;
public static class Test {
private static void wrileLine( String line ) {
Hm.OutputPane.Output( line + "\r\n" ) ;
}
private static void writeError( String testName , String message ) {
wrileLine( @"Error( " + testName + @" ) : " + message ) ;
}
private static void writeException( String testName , Exception exception ) {
writeError( testName , exception.GetType().FullName + @" , " + exception.Message ) ;
}
private static void testStr( String testName , Object @value ) {
try {
Hm.Macro.IFunctionResult functionResult = Hm.Macro.Function( @"str" , @value ) ;
if ( null != functionResult ) {
Exception exception = functionResult.Error ;
if ( null == exception ) {
Object strResult = functionResult.Result ;
if ( null != strResult ) {
wrileLine( testName + @" = " + ( (String) strResult ) ) ;
} else {
writeError( testName , @"str() Result is null." ) ;
}
} else {
writeException( testName , exception ) ;
}
} else {
writeError( testName , @"Function Result is null." ) ;
}
} catch ( Exception exception ) {
writeException( testName , exception ) ;
}
}
public static IntPtr Run() {
testStr( @"Int32-MaxValue" , (Object) ( Int32.MaxValue ) ) ;
testStr( @"Double-MaxValue" , (Object) ( Double.MaxValue ) ) ;
testStr( @"Int32-MinValue" , (Object) ( Int32.MinValue ) ) ;
testStr( @"Double-MinValue" , (Object) ( Double.MinValue ) ) ;
return (IntPtr) 0 ;
}
}
//---------------- StrFloat.dll ----------------
//---------------- StrFloat.mac ----------------
#hmDotNet = loaddll( hidemarudir + @"\hm.NET.dll" ) ;
disableerrormsg ;
setfloatmode 1 ;
#testResult = dllfuncw(
#hmDotNet ,
@"CallMethod" ,
currentmacrodirectory + @"\StrFloat.dll" ,
@"Test" ,
@"Run"
) ;
setfloatmode 0 ;
enableerrormsg ;
endmacro ;
//---------------- StrFloat.mac ----------------
表示されたエラーメッセージは次の通りです。
---------------------------
エラー
---------------------------
マクロエラー:数値が指定されるべき所に数値以外のものが指定されています。
エラー箇所の内容(変換した内容):
##_tmp_dll_id_ret = dllfuncw( 1 , "SetTmpVar" , str( $AsMacroArs_0_25939 ) );
##_tmp_dll_id_ret = 0;
---------------------------
OK
---------------------------
実行結果のアウトプット枠の内容は以下の通りです。
Int32-MaxValue = 2147483647
Error( Double-MaxValue ) : System.InvalidOperationException , HidemaruMacroEvalException
Error( Int32-MinValue ) : System.InvalidOperationException , HidemaruMacroEvalException
Error( Double-MinValue ) : System.InvalidOperationException , HidemaruMacroEvalException
環境は、
・秀丸エディタ v8.98β10 x64 Float
・hm.Net.dll v2.0.0.1
です。
|
|