ボタンの設定1

Top Before Next

 


データ出力サンプル

以下の設定内容をコピーし、YCalcのボタン上で右クリックしメニュー内の貼り付けで設定できます。

 

π

定数を出力します。

3.141592653589793

 

1.5倍

計算式をを出力します。

*1.5

 

平方根関数を出力します。数値または式を入力後 ")" で閉じてから計算実行ボタンを押してください。

sqr(

 

計算実行

カーソル行を計算します。単独で指定してください。プログラム内では使用できません。

ExecLine

 

 


プログラムサンプル1

カーソル行の数値、または式に対して各演算を行い、次の行に計算結果を出力します。

 

平方根計算

カーソル行を平方根計算します。

'sqr
dim n
n = sqr( Calc( GetCurrentLine ) )
SetNextLine
print n

 

税込計算

カーソル行を5%税込計算します。(小数点以下は切り捨てます)

'込
dim n
n = int( Calc( GetCurrentLine ) * 1.05 )
SetNextLine
print n

 

税抜計算

カーソル行を5%税抜計算します。(小数点以下は切り捨てます)

'抜
dim n
n = int( Calc( GetCurrentLine ) / 1.05 )
SetNextLine
print n

 

小数点以下を切り捨て計算

カーソル行を小数点以下切り捨て計算します。

'int
dim n
n = int( Calc( GetCurrentLine ) )
SetNextLine
print n

 

1000分の1で四捨五入計算

カーソル行を1000分の1で四捨五入します。

'rd2
dim n
n = round( Calc( GetCurrentLine ), 2 )
SetNextLine
print n

 

sin計算

カーソル行の度数を sin 計算します。

'sin
dim n
n = sin( Calc( GetCurrentLine ) * 3.141592653589793 / 180 )
SetNextLine
print n

 


プログラムサンプル2

繰り返し計算や、ボタンの色や、ラベルを利用したりプログラムです。

 

繰り返し計算

2の1〜16乗を出力します。

'repeat

dim n

n = 1

while ( n <= 16 ) {

        print pow( 2, n ), "\n"

        n = n + 1

}

 

シフトボタン

ボタンの色を変えます。他のプログラムから利用できます。例として21番のボタンに設定します。

'S
if ( GetButtonBackColor == 0x0000b0 ) {
        SetButtonBackColor( 0xc0c0c0 )
}
else{
        SetButtonBackColor( 0x0000b0 )
}

 

シンプルメモリー

上記のシフトボタンを利用したメモリーです。例としてシフトボタンは21番、メモリーボタンは1番とします。

メモリーボタンに以下のプログラムをセットします。

使い方は、シフトボタンを押してメモリーボタンを押すと代入、メモリーボタンのみを押すと出力になります。

'Simple Memory
SetButton(21)
if ( GetButtonBackColor == 0x0000b0 ) {
        SetButtonBackColor( 0xc0c0c0 )
        SetButton(1)
        SetButtonLabel( Str( Calc( GetCurrentLine ) ) )
}
else{
        SetButton(1)
        print GetButtonLabel
}