Rename t_items.qc to items.qc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / command / rpn.qc
1 #include "rpn.qh"
2 #include "command.qh"
3
4
5 // ========================================
6 //  RPN command code, written by divVerent
7 //  Last updated: December 28th, 2011
8 // ========================================
9
10 string rpn_pop()
11 {
12         if(rpn_sp > 0) {
13                 --rpn_sp;
14                 return rpn_stack[rpn_sp];
15         } else {
16                 LOG_INFO("rpn: stack underflow");
17                 rpn_error = true;
18                 return "";
19         }
20 }
21 void rpn_push(string s)
22 {
23         if(rpn_sp < MAX_RPN_STACK) {
24                 rpn_stack[rpn_sp] = s;
25                 ++rpn_sp;
26         } else {
27                 LOG_INFO("rpn: stack overflow");
28                 rpn_error = true;
29         }
30 }
31 string rpn_get()
32 {
33         if(rpn_sp > 0) {
34                 return rpn_stack[rpn_sp - 1];
35         } else {
36                 LOG_INFO("rpn: empty stack");
37                 rpn_error = true;
38                 return "";
39         }
40 }
41 void rpn_set(string s)
42 {
43         if(rpn_sp > 0) {
44                 rpn_stack[rpn_sp - 1] = s;
45         } else {
46                 LOG_INFO("rpn: empty stack");
47                 rpn_error = true;
48         }
49 }
50
51 float rpn_getf() { return stof(rpn_get()); }
52 float rpn_popf() { return stof(rpn_pop()); }
53 void rpn_pushf(float f) { return rpn_push(sprintf("%.9g", f)); }
54 void rpn_setf(float f) { return rpn_set(sprintf("%.9g", f)); }
55
56 SHUTDOWN(_rpndb)
57 {
58         if(rpn_db)
59                 db_close(rpn_db);
60 }
61
62 void GenericCommand_rpn(int request, int argc, string command)
63 {
64         switch(request)
65         {
66                 case CMD_REQUEST_COMMAND:
67                 {
68                         float i, j, f, f2, f3, rpnpos;
69                         //vector rgb;
70                         string s, s2, rpncmd;
71
72                         if(!rpn_db)
73                         {
74                                 rpn_db = db_create();
75                                 db_put(rpn_db, "stack.pointer", "0");
76                                 db_put(rpn_db, "stack.pos", "-1");
77                         }
78
79                         if(argc >= 2)
80                         {
81                                 rpn_sp = 0;
82                                 rpn_error = false;
83                                 for(rpnpos = 1; rpnpos < argc; ++rpnpos)
84                                 {
85                                         rpncmd = argv(rpnpos);
86                                         f = strlen(rpncmd);
87                                         if(rpncmd == "") {
88                                         } else if(stof(substring(rpncmd, 0, 1)) > 0) {
89                                                 rpn_push(rpncmd);
90                                         } else if(substring(rpncmd, 0, 1) == "0") {
91                                                 rpn_push(rpncmd);
92                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "+") {
93                                                 rpn_push(rpncmd);
94                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "-") {
95                                                 rpn_push(rpncmd);
96                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "/") {
97                                                 rpn_push(substring(rpncmd, 1, strlen(rpncmd) - 1));
98                                         } else if(rpncmd == "clear") {
99                                                 rpn_sp = 0;
100                                         } else if(rpncmd == "def" || rpncmd == "=") {
101                                                 s = rpn_pop();
102                                                 s2 = rpn_pop();
103
104                                                 if(s2 != "")
105                                                 {
106                                                         #ifdef MENUQC
107                                                         registercvar(s2, "", 0);
108                                                         #else
109                                                         registercvar(s2, "");
110                                                         #endif
111                                                         if(!rpn_error) // don't change cvars if a stack error had happened!
112                                                                 cvar_set(s2, s);
113                                                 }
114                                                 else
115                                                 {
116                                                         LOG_INFO("rpn: empty cvar name for 'def'");
117                                                         rpn_error = true;
118                                                 }
119                                         } else if(rpncmd == "defs" || rpncmd == "@") {
120                                                 s = "";
121                                                 i = rpn_popf();
122                                                 j = (i == 0);
123                                                 while(rpn_sp > 1 && (j || i > 0))
124                                                 {
125                                                         s = strcat("/", rpn_pop(), " ", s);
126                                                         --i;
127                                                 }
128                                                 s2 = rpn_pop();
129                                                 if(s2 != "")
130                                                 {
131                                                         #ifdef MENUQC
132                                                         registercvar(s2, "", 0);
133                                                         #else
134                                                         registercvar(s2, "");
135                                                         #endif
136                                                         if(!rpn_error) // don't change cvars if a stack error had happened!
137                                                                 cvar_set(s2, s);
138                                                 }
139                                                 else
140                                                 {
141                                                         LOG_INFO("rpn: empty cvar name for 'defs'");
142                                                         rpn_error = true;
143                                                 }
144                                         } else if(rpncmd == "load") {
145                                                 rpn_set(cvar_string(rpn_get()));
146                                         } else if(rpncmd == "exch") {
147                                                 s = rpn_pop();
148                                                 s2 = rpn_get();
149                                                 rpn_set(s);
150                                                 rpn_push(s2);
151                                         } else if(rpncmd == "dup") {
152                                                 rpn_push(rpn_get());
153                                         } else if(rpncmd == "pop") {
154                                                 rpn_pop();
155                                         } else if(rpncmd == "add" || rpncmd == "+") {
156                                                 f = rpn_popf();
157                                                 rpn_setf(rpn_getf() + f);
158                                         } else if(rpncmd == "sub" || rpncmd == "-") {
159                                                 f = rpn_popf();
160                                                 rpn_setf(rpn_getf() - f);
161                                         } else if(rpncmd == "mul" || rpncmd == "*") {
162                                                 f = rpn_popf();
163                                                 rpn_setf(rpn_getf() * f);
164                                         } else if(rpncmd == "div" || rpncmd == "/") {
165                                                 f = rpn_popf();
166                                                 rpn_setf(rpn_getf() / f);
167                                         } else if(rpncmd == "mod" || rpncmd == "%") {
168                                                 f = rpn_popf();
169                                                 f2 = rpn_getf();
170                                                 rpn_setf(f2 - f * floor(f2 / f));
171                                         } else if(rpncmd == "pow" || rpncmd == "**") {
172                                                 f = rpn_popf();
173                                                 rpn_setf(rpn_getf() ** f);
174                                         } else if(rpncmd == "bitand" || rpncmd == "&") {
175                                                 f = rpn_popf();
176                                                 rpn_setf(rpn_getf() & f);
177                                         } else if(rpncmd == "bitor" || rpncmd == "|") {
178                                                 f = rpn_popf();
179                                                 rpn_setf(rpn_getf() | f);
180                                         } else if(rpncmd == "bitxor" || rpncmd == "^") {
181                                                 f = rpn_popf();
182                                                 rpn_setf(rpn_getf() ^ f);
183                                         } else if(rpncmd == "and" || rpncmd == "&&") {
184                                                 f = rpn_popf();
185                                                 rpn_setf(rpn_getf() && f);
186                                         } else if(rpncmd == "or" || rpncmd == "||") {
187                                                 f = rpn_popf();
188                                                 rpn_setf(rpn_getf() || f);
189                                         } else if(rpncmd == "xor" || rpncmd == "^^") {
190                                                 f = rpn_popf();
191                                                 rpn_setf(!rpn_getf() != !f);
192                                         } else if(rpncmd == "bitnot") {
193                                                 rpn_setf(~rpn_popf());
194                                         } else if(rpncmd == "not") {
195                                                 rpn_setf(!rpn_popf());
196                                         } else if(rpncmd == "abs") {
197                                                 rpn_setf(fabs(rpn_getf()));
198                                         } else if(rpncmd == "sgn") {
199                                                 f = rpn_getf();
200                                                 if(f < 0)
201                                                         rpn_set("-1");
202                                                 else if(f > 0)
203                                                         rpn_set("1");
204                                                 else
205                                                         rpn_set("0");
206                                         } else if(rpncmd == "neg" || rpncmd == "~") {
207                                                 rpn_setf(-rpn_getf());
208                                         } else if(rpncmd == "floor" || rpncmd == "f") {
209                                                 rpn_setf(floor(rpn_getf()));
210                                         } else if(rpncmd == "ceil" || rpncmd == "c") {
211                                                 rpn_setf(ceil(rpn_getf()));
212                                         } else if(rpncmd == "exp") {
213                                                 rpn_setf(exp(rpn_getf()));
214                                         } else if(rpncmd == "log") {
215                                                 rpn_setf(exp(rpn_getf()));
216                                         } else if(rpncmd == "sin") {
217                                                 rpn_setf(sin(rpn_getf()));
218                                         } else if(rpncmd == "cos") {
219                                                 rpn_setf(cos(rpn_getf()));
220                                         } else if(rpncmd == "max") {
221                                                 f = rpn_popf();
222                                                 f2 = rpn_getf();
223                                                 rpn_setf(max(f2, f));
224                                         } else if(rpncmd == "min") {
225                                                 f = rpn_popf();
226                                                 f2 = rpn_getf();
227                                                 rpn_setf(min(f2, f));
228                                         } else if(rpncmd == "bound") {
229                                                 f = rpn_popf();
230                                                 f2 = rpn_popf();
231                                                 f3 = rpn_getf();
232                                                 rpn_setf(bound(f3, f2, f));
233                                         } else if(rpncmd == "when") {
234                                                 f = rpn_popf();
235                                                 s = rpn_pop();
236                                                 s2 = rpn_get();
237                                                 if(f)
238                                                         rpn_set(s2);
239                                                 else
240                                                         rpn_set(s);
241                                         } else if(rpncmd == ">" || rpncmd == "gt") {
242                                                 f = rpn_popf();
243                                                 rpn_setf(rpn_getf() > f);
244                                         } else if(rpncmd == "<" || rpncmd == "lt") {
245                                                 f = rpn_popf();
246                                                 rpn_setf(rpn_getf() < f);
247                                         } else if(rpncmd == "==" || rpncmd == "eq") {
248                                                 f = rpn_popf();
249                                                 rpn_setf(rpn_getf() == f);
250                                         } else if(rpncmd == ">=" || rpncmd == "ge") {
251                                                 f = rpn_popf();
252                                                 rpn_setf(rpn_getf() >= f);
253                                         } else if(rpncmd == "<=" || rpncmd == "le") {
254                                                 f = rpn_popf();
255                                                 rpn_setf(rpn_getf() <= f);
256                                         } else if(rpncmd == "!=" || rpncmd == "ne") {
257                                                 f = rpn_popf();
258                                                 rpn_setf(rpn_getf() != f);
259                                         } else if(rpncmd == "rand") {
260                                                 rpn_setf(ceil(random() * rpn_getf()) - 1);
261                                         } else if(rpncmd == "crc16") {
262                                                 rpn_setf(crc16(false, rpn_get()));
263                                         } else if(rpncmd == "put") {
264                                                 s2 = rpn_pop();
265                                                 if (!rpn_error)
266                                                 {
267                                                         s = rpn_pop();
268                                                         if (!rpn_error)
269                                                                 db_put(rpn_db, s, s2);
270                                                 }
271                                         } else if(rpncmd == "get") {
272                                                 s = rpn_pop();
273                                                 if (!rpn_error)
274                                                         rpn_push(db_get(rpn_db, s));
275                                         } else if(rpncmd == "dbpush") {
276                                                 s = rpn_pop();
277                                                 if(!rpn_error)
278                                                 {
279                                                         i = stof(db_get(rpn_db, "stack.pointer"));
280                                                         db_put(rpn_db, "stack.pointer", ftos(i+1));
281                                                         db_put(rpn_db, strcat("stack.", ftos(i)), s);
282                                                         if(!i)
283                                                                 db_put(rpn_db, "stack.pos", "0");
284                                                 }
285                                         } else if(rpncmd == "dbpop") {
286                                                 i = stof(db_get(rpn_db, "stack.pointer"));
287                                                 if(i)
288                                                 {
289                                                         s = ftos(i-1);
290                                                         db_put(rpn_db, "stack.pointer", s);
291                                                         rpn_push(db_get(rpn_db, strcat("stack.", s)));
292                                                         j = stof(db_get(rpn_db, "stack.pos"));
293                                                         if(j >= i)
294                                                                 db_put(rpn_db, "stack.pos", ftos(i-2));
295                                                 } else {
296                                                         rpn_error = 1;
297                                                         LOG_INFO("rpn: database underflow");
298                                                 }
299                                         } else if(rpncmd == "dbget") {
300
301                                                 i = stof(db_get(rpn_db, "stack.pointer"));
302                                                 if(i)
303                                                 {
304                                                         rpn_push(db_get(rpn_db, strcat("stack.", ftos(i-1))));
305                                                 } else {
306                                                         rpn_error = 1;
307                                                         LOG_INFO("rpn: database empty");
308                                                 }
309                                         } else if(rpncmd == "dblen") {
310                                                 rpn_push(db_get(rpn_db, "stack.pointer"));
311                                         } else if(rpncmd == "dbclr") {
312                                                 db_close(rpn_db);
313                                                 rpn_db = db_create();
314                                                 db_put(rpn_db, "stack.pointer", "0");
315                                                 db_put(rpn_db, "stack.pos", "-1");
316                                         } else if(rpncmd == "dbsave") {
317                                                 s = rpn_pop();
318                                                 if(!rpn_error)
319                                                         db_save(rpn_db, s);
320                                         } else if(rpncmd == "dbload") {
321                                                 s = rpn_pop();
322                                                 if(!rpn_error)
323                                                 {
324                                                         db_close(rpn_db);
325                                                         rpn_db = db_load(s);
326                                                 }
327                                         } else if(rpncmd == "dbins") {
328                                                 s = rpn_pop();
329                                                 if(!rpn_error)
330                                                         //if(rpn_sp > 0)
331                                                 {
332                                                         j = stof(db_get(rpn_db, "stack.pointer"));
333                                                         i = stof(db_get(rpn_db, "stack.pos"));
334
335                                                         if(i < 0)
336                                                         {
337                                                                 i = 0;
338                                                                 db_put(rpn_db, "stack.pos", "0");
339                                                         }
340
341                                                         db_put(rpn_db, "stack.pointer", ftos(j+1));
342                                                         for(--j; j >= i; --j)
343                                                         {
344                                                                 db_put(rpn_db, strcat("stack.", ftos(j+1)),
345                                                                                          db_get(rpn_db, (strcat("stack.", ftos(j))))
346                                                                         );
347                                                         }
348                                                         db_put(rpn_db, strcat("stack.", ftos(i)), s);
349                                                 }
350                                         } else if(rpncmd == "dbext") {
351                                                 j = stof(db_get(rpn_db, "stack.pointer"));
352                                                 i = stof(db_get(rpn_db, "stack.pos"));
353                                                 if(!j)
354                                                 {
355                                                         rpn_error = true;
356                                                         LOG_INFO("rpn: empty database");
357                                                 } else {
358                                                         --j;
359                                                         rpn_push(db_get(rpn_db, strcat("stack.", ftos(i))));
360                                                         db_put(rpn_db, "stack.pointer", ftos(j));
361                                                         if(i == j)
362                                                         {
363                                                                 db_put(rpn_db, "stack.pos", ftos(j-1));
364                                                         } else {
365                                                                 while(i < j)
366                                                                 {
367                                                                         db_put(rpn_db, strcat("stack.", ftos(i)),
368                                                                                                  db_get(rpn_db, (strcat("stack.", ftos(i+1))))
369                                                                                 );
370                                                                         ++i;
371                                                                 }
372                                                         }
373                                                 }
374                                         } else if(rpncmd == "dbread") {
375                                                 s = db_get(rpn_db, "stack.pos");
376                                                 if(stof(s) >= 0)
377                                                 {
378                                                         rpn_push(db_get(rpn_db, strcat("stack.", s)));
379                                                 } else {
380                                                         rpn_error = 1;
381                                                         LOG_INFO("rpn: empty database");
382                                                 }
383                                         } else if(rpncmd == "dbat") {
384                                                 rpn_push(db_get(rpn_db, "stack.pos"));
385                                         } else if(rpncmd == "dbmov") {
386                                                 j = stof(db_get(rpn_db, "stack.pointer"));
387                                                 i = stof(db_get(rpn_db, "stack.pos"));
388                                                 i += rpn_popf();
389                                                 if(!rpn_error)
390                                                 {
391                                                         if(i < 0 || i >= j)
392                                                         {
393                                                                 LOG_INFO("rpn: database cursor out of bounds");
394                                                                 rpn_error = true;
395                                                         }
396                                                         if(!rpn_error)
397                                                         {
398                                                                 db_put(rpn_db, "stack.pos", ftos(i));
399                                                         }
400                                                 }
401                                         } else if(rpncmd == "dbgoto") {
402                                                 s = rpn_pop();
403                                                 j = stof(db_get(rpn_db, "stack.pointer"));
404                                                 if(!j)
405                                                 {
406                                                         rpn_error = true;
407                                                         LOG_INFO("rpn: empty database, cannot move cursor");
408                                                 }
409                                                 if(!rpn_error)
410                                                 {
411                                                         if(s == "end")
412                                                                 i = stof(db_get(rpn_db, "stack.pointer"))-1;
413                                                         else if(s == "beg")
414                                                                 i = 0;
415                                                         else
416                                                                 i = stof(s);
417
418                                                         j = stof(db_get(rpn_db, "stack.pointer"));
419                                                         if(i < 0 || i >= j)
420                                                         {
421                                                                 LOG_INFO("rpn: database cursor destination out of bounds");
422                                                                 rpn_error = true;
423                                                         }
424                                                         if(!rpn_error)
425                                                         {
426                                                                 db_put(rpn_db, "stack.pos", ftos(i));
427                                                         }
428                                                 }
429                                         } else if(rpncmd == "union") {
430                                                 // s s2 union
431                                                 s2 = rpn_pop();
432                                                 s = rpn_get();
433                                                 f = tokenize_console(s);
434                                                 f2 = tokenize_console(strcat(s, " ", s2));
435                                                 // tokens 0..(f-1) represent s
436                                                 // tokens f..f2 represent s2
437                                                 // UNION: add all tokens to s that are in s2 but not in s
438                                                 s = "";
439                                                 for(i = 0; i < f; ++i)
440                                                         s = strcat(s, " ", argv(i));
441                                                 for(i = f; i < f2; ++i) {
442                                                         for(j = 0; j < f; ++j)
443                                                                 if(argv(i) == argv(j))
444                                                                         goto skip_union;
445                                                         s = strcat(s, " ", argv(i));
446 LABEL(skip_union)
447                                                 }
448                                                 if(substring(s, 0, 1) == " ")
449                                                         s = substring(s, 1, 99999);
450                                                 rpn_set(s);
451                                                 tokenize_console(command);
452                                         } else if(rpncmd == "intersection") {
453                                                 // s s2 intersection
454                                                 s2 = rpn_pop();
455                                                 s = rpn_get();
456                                                 f = tokenize_console(s);
457                                                 f2 = tokenize_console(strcat(s, " ", s2));
458                                                 // tokens 0..(f-1) represent s
459                                                 // tokens f..f2 represent s2
460                                                 // INTERSECTION: keep only the tokens from s that are also in s2
461                                                 s = "";
462                                                 for(i = 0; i < f; ++i) {
463                                                         for(j = f; j < f2; ++j)
464                                                                 if(argv(i) == argv(j))
465                                                                 {
466                                                                         s = strcat(s, " ", argv(i));
467                                                                         break;
468                                                                 }
469                                                 }
470                                                 if(substring(s, 0, 1) == " ")
471                                                         s = substring(s, 1, 99999);
472                                                 rpn_set(s);
473                                                 tokenize_console(command);
474                                         } else if(rpncmd == "difference") {
475                                                 // s s2 difference
476                                                 s2 = rpn_pop();
477                                                 s = rpn_get();
478                                                 f = tokenize_console(s);
479                                                 f2 = tokenize_console(strcat(s, " ", s2));
480                                                 // tokens 0..(f-1) represent s
481                                                 // tokens f..f2 represent s2
482                                                 // DIFFERENCE: keep only the tokens from s that are not in s2
483                                                 s = "";
484                                                 for(i = 0; i < f; ++i) {
485                                                         for(j = f; j < f2; ++j)
486                                                                 if(argv(i) == argv(j))
487                                                                         goto skip_difference;
488                                                         s = strcat(s, " ", argv(i));
489 LABEL(skip_difference)
490                                                 }
491                                                 if(substring(s, 0, 1) == " ")
492                                                         s = substring(s, 1, 99999);
493                                                 rpn_set(s);
494                                                 tokenize_console(command);
495                                         } else if(rpncmd == "shuffle") {
496                                                 // s shuffle
497                                                 s = rpn_get();
498                                                 f = tokenize_console(s);
499
500                                                 for(i = 0; i < f - 1; ++i) {
501                                                         // move a random item from i..f-1 to position i
502                                                         s = "";
503                                                         f2 = floor(random() * (f - i) + i);
504                                                         for(j = 0; j < i; ++j)
505                                                                 s = strcat(s, " ", argv(j));
506                                                         s = strcat(s, " ", argv(f2));
507                                                         for(j = i; j < f; ++j)
508                                                                 if(j != f2)
509                                                                         s = strcat(s, " ", argv(j));
510                                                         f = tokenize_console(s);
511                                                 }
512
513                                                 if(substring(s, 0, 1) == " ")
514                                                         s = substring(s, 1, 99999);
515                                                 rpn_set(s);
516                                                 tokenize_console(command);
517                                         } else if(rpncmd == "fexists_assert") {
518                                                 s = rpn_pop();
519                                                 if(!rpn_error)
520                                                 {
521                                                         if (!fexists(s))
522                                                         {
523                                                                 LOG_INFO("rpn: ERROR: ", s, " does not exist!");
524                                                                 rpn_error = true;
525                                                         }
526                                                 }
527                                         } else if(rpncmd == "fexists") {
528                                                 s = rpn_get();
529                                                 if(!rpn_error)
530                                                 {
531                                                         if (fexists(s))
532                                                                 rpn_setf(1);
533                                                         else
534                                                                 rpn_setf(0);
535                                                 }
536                                         } else if(rpncmd == "localtime") {
537                                                 rpn_set(strftime(true, rpn_get()));
538                                         } else if(rpncmd == "gmtime") {
539                                                 rpn_set(strftime(false, rpn_get()));
540                                         } else if(rpncmd == "time") {
541                                                 rpn_pushf(time);
542                                         } else if(rpncmd == "digest") {
543                                                 s = rpn_pop();
544                                                 rpn_set(digest_hex(s, rpn_get()));
545                                         } else if(rpncmd == "sprintf1s") {
546                                                 s = rpn_pop();
547                                                 rpn_set(sprintf(s, rpn_get()));
548                                         } else if(rpncmd == "eval") {
549                                                 s = rpn_pop();
550                                                 command = strcat(s, substring(command, argv_end_index(rpnpos), -1));
551                                                 argc = tokenize_console(command);
552                                                 rpnpos = -1;
553                                         } else {
554                                                 rpn_push(cvar_string(rpncmd));
555                                         }
556                                         if(rpn_error)
557                                                 break;
558                                 }
559                                 while(rpn_sp > 0)
560                                 {
561                                         s = rpn_pop();
562                                         LOG_INFO("rpn: still on stack: ", s);
563                                 }
564                         }
565
566                         return;
567                 }
568
569                 default:
570                 case CMD_REQUEST_USAGE:
571                 {
572                         LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " rpn EXPRESSION...");
573                         LOG_HELP("    Operator description (x: string, s: set, f: float):");
574                         LOG_HELP("    x pop ----------------------------->     : removes the top");
575                         LOG_HELP("    x dup -----------------------------> x x : duplicates the top");
576                         LOG_HELP("    x x exch --------------------------> x x : swap the top two");
577                         LOG_HELP("    /cvarname load --------------------> x   : loads a cvar");
578                         LOG_HELP("    /cvarname x def ------------------->     : writes to a cvar");
579                         LOG_HELP("    f f add|sub|mul|div|mod|pow -------> f   : adds/... two numbers");
580                         LOG_HELP("    f f and|or|xor|bitand|bitor|bitxor > f   : logical and bitwise operations");
581                         LOG_HELP("    f f eq|ne|gt|ge|lt|le|max|min -----> f   : compares two numbers");
582                         LOG_HELP("    f neg|abs|sgn|rand|floor|ceil------> f   : negates/... a number");
583                         LOG_HELP("    f not|bitnot ----------------------> f   : logical and bitwise negation");
584                         LOG_HELP("    f exp|log|sin|cos -----------------> f   : exponential function & Co.");
585                         LOG_HELP("    f f f bound -----------------------> f   : bounds the middle number");
586                         LOG_HELP("    f1 f2 b when ----------------------> f   : f1 if b, f2 otherwise");
587                         LOG_HELP("    s s union|intersection|difference -> s   : set operations");
588                         LOG_HELP("    s shuffle -------------------------> s   : randomly arrange elements");
589                         LOG_HELP("    /key /value put ------------------->     : set a database key");
590                         LOG_HELP("    /key get --------------------------> s   : get a database value");
591                         LOG_HELP("    x dbpush -------------------------->     : pushes the top onto the database");
592                         LOG_HELP("    dbpop|dbget -----------------------> x   : removes/reads DB's top");
593                         LOG_HELP("    dblen|dbat ------------------------> f   : gets the DB's size/cursor pos");
594                         LOG_HELP("    dbclr ----------------------------->     : clear the DB");
595                         LOG_HELP("    s dbsave|dbload-------------------->     : save/load the DB to/from a file");
596                         LOG_HELP("    x dbins --------------------------->     : moves the top into the DB");
597                         LOG_HELP("    dbext|dbread ----------------------> x   : extract/get from the DB's cursor");
598                         LOG_HELP("    f dbmov|dbgoto -------------------->     : move or set the DB's cursor");
599                         LOG_HELP("    s localtime -----------------------> s   : formats the current local time");
600                         LOG_HELP("    s gmtime --------------------------> s   : formats the current UTC time");
601                         LOG_HELP("    time ------------------------------> f   : seconds since VM start");
602                         LOG_HELP("    s /MD4 digest ---------------------> s   : MD4 digest");
603                         LOG_HELP("    s /SHA256 digest ------------------> s   : SHA256 digest");
604                         LOG_HELP("    s /formatstring sprintf1s ---------> s   : sprintf with 1 string (pad, cut)");
605                         LOG_HELP("    s eval ---------------------------->     : does something eval");
606                         LOG_HELP("    Set operations operate on 'such''strings'.");
607                         LOG_HELP("    Unknown tokens insert their cvar value.");
608                         return;
609                 }
610         }
611 }