HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2011
0215
インコみんなのuserdef.asを紹介してください9解決


インコ

リンク

2011/2/15(Tue) 05:15:08|NO.37125

実行時に勝手に読み込んでくれる便利な

"userdef.as" !!

皆さんはどのようなものを定義していますか?

全く使ってないとか
もう100KBを超えているとか

なんでもどうぞ。

私のはたったの二行

delete"hsptmp"
delete"obj"

です。



この記事に返信する


f3d()

リンク

2011/2/15(Tue) 09:48:17|NO.37128

うむ
#include "userdef.as"



ひらまる

リンク

2011/2/15(Tue) 10:43:15|NO.37130

とりあえずhspdef内の#include "userdef.as"を、一番下の

#define global logmes(%1) : #endif #addition "userdef.as";ここ #endif #else #addition "hsp261cmp.as"
に変えています。
userdef内でhsp標準マクロが使いたいので。

あとはWindowsAPI定数などを記述した20000行のファイルをインクルードしているので、
コンパイルに2〜3秒かかってしまいます。 拡張ランタイムなどでどうにかできないのでしょうか…



ESZET@雪崩の中の松茸

リンク

2011/2/15(Tue) 18:31:31|NO.37133

使ってないなぁ userdefalt。
delete "hsptmp"
delete "obj"
これ書いとくか。バックアップはこまめに取ってるし



トレストイナ

リンク

2011/2/15(Tue) 19:10:56|NO.37138

こんな感じ。
一時ファイルを削除するソースは標準で入ってても良いと思う。


#ifdef _debug exist "hsptmp":if strsize!=-1:delete "hsptmp" exist "obj":if strsize!=-1:delete "obj" #endif #define global clear_window color:boxf:color 255,255,255:pos 0,0 #define get_color pget mousex,mousey:title ""+ginfo_r+","+ginfo_g+","+ginfo_b #module ; モジュール変数の添え字を返す #defcfunc getaptr var _p1 mref HSPCTX, 68 dupptr vptr, HSPCTX.207, 8, 4 return vptr(1) #global



p、USAGI

リンク

2011/2/16(Wed) 13:52:35|NO.37141

これだけ。(gradf用)

#define global ctype RGB(%1=0,%2=0,%3=0) (%1 <<16 | %2 << 8 | %3)



玄冬

リンク

2011/2/18(Fri) 18:00:41|NO.37173


;============制御構造=================== ;-----------制御マクロの再定義---------- ;while #define global U_while(%1=1) repeat -1 %c if %1 { #define global U_wend } else : break %c loop ;do #define global U_do repeat -1 #define global U_until(%1=1) if %1 : break %c loop ;for #define global U_for(%1,%2=0,%3=0,%4=1) %tfor_ %s4 %s1 %1 = %2 %c repeat -1 %c if %1 < %3 { #define global U_next %tfor_ %o += %o %c } else : break %c loop ;-----------------n次foreach-------------------- #define global U_foreach2(%1=0) repeat length2(%1), 0 ;2次元目でforeach #define global U_foreach3(%1=0) repeat length3(%1), 0 ;3次元目でforeach #define global U_foreach4(%1=0) repeat length4(%1), 0 ;4次元目でforeach ;==============汎用=============== ;------------------------------ ;color命令をカラーコード(#ffaa80など)で表せる ;------------------------------ #define global U_color(%1 = "#000000") func_color str(%1) ;----------------getkeyの関数化-------------- #define global U_check_key(%1) cfunc_check_key(int(%1)) ;==============数学関連=============== ;---------------2点間の距離を求める--------------- #define global ctype U_distance(%1,%2,%3,%4) sqrt((double(%1) - %3) * (double(%1) - %3)+(double(%2) - %4) * (double(%2) - %4));(%1, %2)と(%3, %4)の距離 ;-------------べき乗------------- #define global ctype U_pow(%1,%2) cfunc_pow(%1,%2) ;%1^%2 ;-------------度数法三角関数------------- #define global ctype U_cos_d(%1) cos(deg2rad(%1)) ;cos #define global ctype U_sin_d(%1) sin(deg2rad(%1)) ;sin #define global ctype U_tan_d(%1) tan(deg2rad(%1)) ;tan #define global ctype U_atan_d(%1, %2 = 1) rad2deg(atan(%1,%2)) ;atan #module mod_user ;==============汎用=============== ;------------------------------ ;color命令をカラーコード(#ffaa80など)で表せる ;------------------------------ #deffunc func_color str p_RGB, local l_color, local l_s l_color = p_RGB if "#" ! strmid(l_color, 0, 1) { dialog "カラーコードの頭に#をつけて下さい。" : end} if strlen(p_RGB) ! 7 { dialog "カラーコードは6桁の十六進数です。" : end} repeat 6,1 l_s = strmid(l_color, cnt, 1) if 0 = (l_s = "0" | l_s = "1" | l_s = "2" | l_s = "3" | l_s = "4" | l_s = "5" | l_s = "6" | l_s = "7" | l_s = "8" | l_s = "9" | l_s = "a" | l_s = "b" | l_s = "c" | l_s = "d" | l_s = "e" | l_s = "f" | l_s = "A" | l_s = "B" | l_s = "C" | l_s = "D" | l_s = "E" | l_s = "F") { dialog "不適当な文字\"" + l_s + "\"が使われています" : end} loop color int("$" + strmid(l_color, 1, 2)), int("$" + strmid(l_color, 3, 2)), int("$" + strmid(l_color, 5, 2)) return ;------------------------------ ;getkeyを命令から関数に変更 ;p_KEY : 調べるキー ;------------------------------ #defcfunc cfunc_check_key int p_KEY, local l_x getkey l_x, p_KEY return l_x ;==============数学関連=============== ;------------------------------ ;べき乗 ;BASE : a^bのa ;EXP : a^bのb ;------------------------------ #defcfunc cfunc_pow double p_BASE, double p_EXP, local l_y l_y = logf(-1);初期値。エラー時用 if p_EXP = int(p_EXP) { ;整数のとき l_y = 1.0 if 0 <= p_EXP { repeat int(p_EXP) l_y *= p_BASE loop } else { repeat abs(int(p_EXP)) l_y /= p_BASE loop } } else { if 0 < p_BASE : l_y = expf(p_EXP * logf(p_BASE)) } return l_y #global // デバッグ時用クリーンアップ命令 #ifdef _DEBUG #module #deffunc _Debug_CleanupStatement_ onexit exist "obj" : if ( strsize >= 0 ) { delete "obj" } exist "hsptmp" : if ( strsize >= 0 ) { delete "hsptmp" } return #global #endif

開いてそのまんまコピペ。

制御マクロの再定義はbreak,continue,looplev,cntを共有したかったので作ったもの。U_forは殆ど使ってないから挙動に自信ない。
U_colorはあったことも忘れてた代物。たぶん$で16進数表記ができることも知らなかった最初期の作。
get_keyは関数化したほうが絶対使いやすい!

後は数学関係。
べき乗a^bはpowfが標準定義マクロにもあるけど、単純にe^b*log(a)してるだけでマイナスに対応してないのが気に食わなかったので実数全体に拡張。
ゲームとかで極座標をラジアンで指定すんのは私の頭では無理なので、度数法三角関数は必須。

デバッグ時用クリーンアップ命令はたぶん昔ここで紹介されてたもの…



seasalt

リンク

2011/2/25(Fri) 18:45:16|NO.37266

参考になります。



ひよこ

リンク

2011/2/25(Fri) 21:23:22|NO.37267

#uselib "KERNEL32.DLL"
#cfunc CreateFile "CreateFileA" int,int,int,int,int,int,int #func CloseHandle "CloseHandle" int #cfunc GetFileAttributes "GetFileAttributesA" int #define OPEN_EXISTING 3 #define FILE_ATTRIBUTE_NORMAL $00000080 #defcfunc cexist str FileName fn = FileName if GetFileAttributes(varptr(fn))==-1 : return -2 hfile = CreateFile(varptr(fn), $C0000000, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) if hfile=-1 : return -1 CloseHandle hfile exist fn return strsize
existの拡張版。
ファイルが存在しないときは、-2
ファイルは存在するが他プロセスによってロックされている場合、-1を返す。
ロックされてなかったら、ファイルのサイズ。

userdef.asもっといろいろ書いてありますが、
見せられないくらい酷いのでこれだけ。



panda

リンク

2011/2/27(Sun) 00:15:31|NO.37285

私は #undef で exist自体を書き換えてますよ



ONION software Copyright 1997-2023(c) All rights reserved.