Retrieve and search chat history: Difference between revisions

m
(New post.)
m (→‎{{header|Wren}}: Minor tidy)
Line 992:
 
However, it is designed to be used primarily as an embedded scripting language and we can therefore ask the host (in this case a C program) to call the necessary functions from its own libraries and pass the results back to Wren. We can then manipulate the date using the above module, search the downloaded files for the string in question and print the results.
<syntaxhighlight lang="ecmascriptwren">/* retrieve_and_search_chat_historyRetrieve_and_search_chat_history.wren */
 
import "./date" for Date
Line 1,060:
<br>
We now embed this in the following C program, build and run. Note that, whilst it would be possible to embed the Wren script ''directly'' into the C program (so there's only a single file), we have refrained from doing so in the interests of clarity.
<syntaxhighlight lang="c">/* gcc retrieve_and_search_chat_historyRetrieve_and_search_chat_history.c -o retrieve_and_search_chat_historyRetrieve_and_search_chat_history -lcurl -lwren -lm */
 
#include <stdio.h>
Line 1,257:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "retrieve_and_search_chat_historyRetrieve_and_search_chat_history.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 1,278:
Sample input/output:
<pre>
$ ./retrieve_and_search_chat_historyRetrieve_and_search_chat_history "now known as"
It's January 9 2022 4:07pm CET just now in Germany.
Searching for 'now known as' in the TCL Chatroom logs for the last 10 days:
9,482

edits