-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_log.axi
72 lines (58 loc) · 1.69 KB
/
functions_log.axi
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
// functions_log.axi - Simple logging functions
//
// These are in an include file to keep the main source file small/tidy
//
// Does simplest possible logging - output in NetLinx Studio's Diagnostics tab.
// Requires you to "Enable NetLinx Internal Diagnostics Messages"
// in the Diagnostics menu first.
//
// The function names are stolen from someone else. See:
// https://proforums.harman.com/amx/discussion/2747/telnet-server
// and blame them for not following good naming conventions :-)
// (can't remember where sCleanAscii() was stolen from)
//
DEFINE_FUNCTION CHAR[5096] sCleanAscii (CHAR sString[])
{
STACK_VAR CHAR sTemp[5096] ;
STACK_VAR INTEGER nCount ;
FOR(nCount = 1; nCount <= LENGTH_STRING(sString); nCount ++)
{
SELECT
{
ACTIVE(sString[nCount] < 32) : // low order ASCII
{
sTemp = "sTemp, ',<', ITOA(sString[nCount]), '>'"
}
ACTIVE(sString[nCount] > 126) : // high order ASCII
{
sTemp = "sTemp, ',<', ITOA(sString[nCount]), '>'"
}
ACTIVE(TRUE) : sTemp = "sTemp, sString[nCount]" ;
}
}
RETURN sTemp ;
}
DEFINE_FUNCTION Debug(char s[])
{
if (length_string(s) > 255)
{ set_length_string(s,255) }
send_string 0, s
}
DEFINE_FUNCTION DebugHex(char s[], char d[])
{
stack_var char hex[5096]
hex = sCleanAscii(d)
Debug("s,hex")
}
DEFINE_FUNCTION Error(char s[])
{
if (length_string(s) > 255)
{ set_length_string(s,255) }
send_string 0, "'ERROR: ',s"
}
DEFINE_FUNCTION ErrorNumber(char s[], integer n)
{
if (length_string(s) > 250)
{ set_length_string(s,250) }
send_string 0, "'ERROR: ',s,' - ',n"
}