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
|
#include <windows.h>
#include <SWI-Prolog.h>
#include "resource.h"
#include "datalistview.h"
HWND gDlv_hWnd;
void
DlvCreate(HWND hWnd)
{
gDlv_hWnd = hWnd;
}
/* Show episode data. */
void
DlvShowEpisode(int iEpisode)
{
int r;
term_t t;
t = PL_new_term_refs(3);
if(!PL_put_integer(t+0, iEpisode))
return;
r = PL_call_predicate(NULL, PL_Q_NORMAL,
PL_predicate("lookup_episode_local", 3, "episode_data"),
t);
if (!r)
return;
/* The episode data is a list of unary compounds,
* whose functor is the key and whose argument is the value. */
{
term_t tHead, tList;
tHead = PL_new_term_ref();
tList = PL_copy_term_ref(t+2);
while (PL_get_list(tList, tHead, tList)) {
atom_t aKey;
const char *szKey;
char *szValue;
term_t tValue;
size_t iArity;
if (!PL_get_name_arity(tHead, &aKey, &iArity))
continue;
szKey = PL_atom_chars(aKey);
if (!PL_get_arg(1, tHead, tValue))
continue;
if (!PL_get_atom_chars(tValue, &szValue))
continue;
//printf("%s/%d: %s\n", szKey, iArity, szValue);
}
}
}
|