見出し画像

コメント機能を使う

 どのプログラム言語でも「コメント機能」があります。「コメント機能」とはプログラムがどのような動作をするのか説明するために使います。例えば、次のようなコードにコメント機能を使ってみます。

  // ウィンドウを中央に配置
	window_width = 640
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y

  1行目のコードが「コメント機能」です。自分が書いたプログラムは他の人からすれば、見た瞬間に理解できるものではないのです。ですので適度に説明を書くことが重要です。

 「コメント機能」のもう一つの使い方としては、書いたプログラムを無視したい時です。例えば次のようなコードです。3行目の「window_width」は実行しても無視されるため、640が入ったままになります。

  // ウィンドウを中央に配置
	window_width = 640
	//window_width = 720
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y


 HSPでは以上の「コメント機能」を使うための書き方が3種類ありますが、好きな書き方を使って良いと思います。下記に例を示します。

パターン1

	window_width = 640
	//window_width = 720	
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y


パターン2

	window_width = 640
	;window_width = 720	
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y


パターン3
このパターンだけは複数の行をまとめて無視することもできます。

	window_width = 640
	/* window_width = 720 */	
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y
	window_width = 640
	/* window_width = 720
	   window_width = 1720 */	
	window_height = 480
	x = ginfo_dispx/2 - window_width/2
	y = ginfo_dispy/2 - window_height/2
	screen 0 , window_width , window_height , 0, x , y


 これらの「コメント機能」を駆使しながらプログラムを書くことで効率良く進めることができます。


Sacchy

よろしければ明日のカップラーメン代のサポートをお願いします!