db_id.anubis
1.82 KB
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
/*
* Created by 伝作 (Densaku).
* Types & Messages generator written by フランスのトトロ aka (David RENÉ)
* Date: 2017-02-15
* Time: 02:18:48
*
*/
transmit system/muscle.anubis
transmit system/convert.anubis
transmit tools/basis.anubis
public type DB_id:
none, //no database Primary Key ID
db_id(
Int value //Integer value of the Primary Key ID
)
.
DB_id message format
====================
public define Message
to_Message
(
DB_id _db_id
)=
with _db_id_message = message((Word32)0), //
forget(add_string(_db_id_message, "__TYPE__", "DB_id"));
if _db_id is
{
//Alternative none (NO TYPE)
none then
forget(add_string(_db_id_message, "__TYPE_ALT__", "none")),
//Alternative db_id
db_id(_value) then
forget(add_string(_db_id_message, "__TYPE_ALT__", "db_id"));
// [type = Int] db_id.value
forget(add_string(_db_id_message, "value", to_String(_value))),
};
_db_id_message
.
public define Maybe(DB_id)
from_Message
(
Message _db_id_message
)=
if find_string(_db_id_message, "__TYPE__") is {failure then failure, success(__type__) then
if find_string(_db_id_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
if __type__ = "DB_id" then
//Alternative none (NO TYPE)
if __type_alt__ = "none" then
success(none)
else //Alternative db_id
if __type_alt__ = "db_id" then //Alternative db_id
// [type = Int] db_id.value
if find_string(_db_id_message, "value") is {failure then failure, success(_value) then
if decimal_scan(_value) is { failure then failure, success(value) then
success(db_id(value))
}}
else
failure //No valid Alternative found !
else
failure //Type not found in message !
}}
.