Lunatic Sol

IT Tips

@関数で10進数を16進数に変換する Part 2

2004-03-30 11:02:00 | @Formula
今朝 N 君に改良版を教えてもらった。こっちの方がスマートなのと、且つ入力チェックもしているので勝手に紹介 (^^;

dec := @Prompt([OkCancelEdit];"Lotus Notes - Dec to Hex conversion";"10進数の値を入力してください";"");
@If(
    @Matches(dec;"+{0-9}"); "";
    @Do(
        @Prompt([Ok];"Lotus Notes - Dec to Hex conversion";"ERROR: 数値を入力して下さい");
        @Return("")
    )
);
n := @TextToNumber(dec);
hex := "";
@DoWhile(
    r := @Modulo(n;16);
    hex := @If( r >= 10 ; @Char( 55 + r) + hex ; @Text(r) + hex);
    n := @Integer(n / 16);
    n >= 16);
hex := @If( n >= 10 ; @Char( 55 + n) + hex ; n = 0 ; ""+ hex ;@Text(n) + hex);
tmp:=@Prompt([OkCancelEdit];"Lotus Notes - Dec to Hex conversion";"16進数変換結果";hex);
■ 関連記事
@関数で10進数を16進数に変換する

最新の画像もっと見る