1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
-
|
|
|
|
|
!
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
!
-
|
|
|
-
|
!
| #ifndef __MODULE_LOG__
#define __MODULE_LOG__
#module "mod_log"
#define MAX_LOG 5
#define MAX_LOG_BUF 4096
#define MAX_LOG_LINE 100
#define LOG_FOLDER "log"
#define WND_WIDTH 480
#define WND_HEIGHT 240
#define SB_VERT 1
#uselib "user32.dll"
#func GetScrollRange "GetScrollRange" int,int,var,var
#func SetScrollPos "SetScrollPos" int,int,var,int
#deffunc log_init
sdim logname, 64, MAX_LOG
sdim logbuf, MAX_LOG_BUF, MAX_LOG
dim wid, MAX_LOG
dim lognodraw, MAX_LOG return
#deffunc log_sel int id
cur = id
return
#define global log_add(%1,%2="") log_add_core %1,%2
#deffunc log_add_core str name, str msg
if "" = name && "" = msg {
tmp = "\n"
exist logname(cur)
bsave logname(cur), tmp, 2, strsize
return
}
tmp = ""+strf("%04d", gettime(0))+"/"+strf("%02d", gettime(1))+"/"+strf("%02d", gettime(3))+" "
tmp+= ""+strf("%02d", gettime(4))+":"+strf("%02d", gettime(5))+":"+strf("%02d", gettime(6))+"|"
if "" = msg : tmp += name + "\n" : else : tmp += name + ":" + msg + "\n"
exist logname(cur)
bsave logname(cur), tmp, strlen(tmp), strsize
if 0 < wid(cur) {
if "" = msg : tmp = name : else : tmp = name + ":" + msg
logbuf(cur) += tmp + "\n"
notesel logbuf(cur)
if MAX_LOG_LINE < noteinfo(0) : notedel 0
noteunsel
if 0 = lognodraw(cur) {
sel = ginfo_sel
gsel wid(cur), 0
ctrl = objinfo(1, 2)
sendmsg ctrl, $b, 0, 0
objprm 1, logbuf(cur)
sel_start = 0 : sel_end = 0
GetScrollRange ctrl, SB_VERT, sel_start, sel_end
SetScrollPos ctrl, SB_VERT, sel_end, 0
sendmsg ctrl, $b1, strlen(logbuf(cur)), -1
sendmsg ctrl, $b, 1, 0
sendmsg ctrl, $b7, 0, 0
gsel sel, 0
}
}
return
#define global log_add2(%1,%2,%3="") log_add2_core %1,%2,%3
#deffunc log_add2_core int id, str name, str msg
cur = id
log_add name, msg
return
#define global log_set(%1,%2=0,%3=-1) log_set_core %1,%2,%3
#deffunc log_set_core str name, int log_div, int wnd
cur = count
count++
dirlist tmp, LOG_FOLDER, 5
if 0 = stat && "." ! LOG_FOLDER : mkdir LOG_FOLDER
if log_div {
tmp = "_"
tmp+= ""+strf("%04d", gettime(0))+strf("%02d", gettime(1))+strf("%02d", gettime(3))
tmp+= ""+strf("%02d", gettime(4))+strf("%02d", gettime(5))+strf("%02d", gettime(6))
} else {
tmp = ""
}
logname(cur) = LOG_FOLDER + "\\" + name + tmp + ".log"
wid(cur) = wnd
lognodraw(cur) = 0
; ログウインドウの作成
if 0 < wnd { ; 0 <= wnd ではない
sel = ginfo_sel
screen wnd,WND_WIDTH,WND_HEIGHT
title "" + name + " Log"
objmode 1
objsize ginfo_winx, 15
pos 0, 0 : chkbox "描画停止", lognodraw(cur)
pos 0, 15 : mesbox logbuf(cur),ginfo_winx,ginfo_winy-15,0
gsel sel
}
log_sel cur
if 0 = log_div : log_add "", ""
return
#global
log_init
#endif
|