1// This file is part of SmallBASIC
2//
3// SmallBASIC RTL - STANDARD COMMANDS
4//
5// This program is distributed under the terms of the GPL v2.0 or later
6// Download the GNU Public License (GPL) from www.gnu.org
7//
8// Copyright(C) 2000 Nicholas Christopoulos
9
10/**
11 * @defgroup date Date and Time
12 */
13
14#if !defined(_blib_h)
15#define _blib_h
16
17#include "common/sys.h"
18#include "common/var.h"
19
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
24void dump_stack(void);
25
26// first class
27void cmd_udp(int);
28bcip_t cmd_push_args(int cmd, bcip_t goto_addr, bcip_t rvid);
29void cmd_call_unit_udp(int cmd, int udp_tid, bcip_t goto_addr, bcip_t rvid);
30void cmd_udpret(void);
31void cmd_crvar(void);
32void cmd_param(void);
33int cmd_exit(void);
34void cmd_let(int);
35void cmd_let_opt();
36void cmd_packed_let();
37void cmd_dim(int);
38void cmd_redim(void);
39void cmd_append(void);
40void cmd_lins(void);
41void cmd_ldel(void);
42void cmd_erase(void);
43void cmd_print(int output);
44void logprint_var(var_t *var);
45void cmd_input(int input);
46void cmd_if(void);
47void cmd_else(void);
48void cmd_elif(void);
49void cmd_endif(void);
50void cmd_for(void);
51void cmd_next(void);
52void cmd_while(void);
53void cmd_wend(void);
54void cmd_until(void);
55void cmd_repeat(void);
56void cmd_select(void);
57void cmd_case(void);
58void cmd_case_else(void);
59void cmd_end_select(void);
60void cmd_gosub(void);
61void cmd_return(void);
62void cmd_on_go(void);
63void cmd_read(void);
64void cmd_data(void);
65void cmd_restore(void);
66void cmd_sort(void);
67void cmd_search(void);
68void cmd_swap(void);
69void cmd_chain(void);
70void cmd_run(int);
71void cmd_try();
72void cmd_catch();
73void cmd_end_try();
74void cmd_call_vfunc();
75void cmd_timer();
76
77var_num_t cmd_math0(long funcCode);
78var_num_t cmd_math1(long funcCode, var_t *arg);
79var_int_t cmd_imath0(long funcCode);
80var_int_t cmd_imath1(long funcCode, var_t *arg);
81void cmd_str1(long funcCode, var_t *arg, var_t *r);
82void cmd_ns1(long funcCode, var_t *arg, var_t *r);
83void cmd_str0(long funcCode, var_t *r);
84void cmd_split(void);
85void cmd_wsplit(void);
86void cmd_wjoin(void);
87void cmd_environ(void);
88void cmd_datedmy(void);
89void cmd_timehms(void);
90void cmd_deriv(void);
91void cmd_diffeq(void);
92
93// not basic, but speed is needed
94void graph_reset(void);
95void cmd_pset(void);
96void cmd_line(void);
97void cmd_rect(void);
98void cmd_circle(void);
99void cmd_arc(void);
100char *draw_getval(const char *src, int *c);
101void cmd_draw(void);
102void cmd_paint(void);
103void cmd_pen(void);
104void cmd_view(void);
105void cmd_window(void);
106void chart_draw(int x1, int y1, int x2, int y2,
107 var_num_t *vals,
108 int count, var_num_t *xvals, int xcount,
109 int chart, int marks);
110void cmd_chart_fstr(var_num_t v, char *buf);
111void cmd_chart(void);
112void cmd_drawpoly(void);
113var_t *par_getm3(void);
114void m3ident(var_num_t[3][3]);
115void m3combine(var_t *, var_num_t[3][3]);
116void cmd_m3ident(void);
117void cmd_m3rotate(void);
118void cmd_m3scale(void);
119void cmd_m3translate(void);
120void cmd_m3apply(void);
121void cmd_intersect(void);
122void cmd_polyext(void);
123void cmd_exprseq(void);
124void cmd_plot(void);
125
126// third class
127void cmd_strN(long, var_t*); // its ok, i want all functions
128// to BMATH
129void cmd_intN(long, var_t*);
130void cmd_numN(long, var_t*);
131void cmd_genfunc(long, var_t*);
132var_num_t line_length(var_num_t Ax, var_num_t Ay, var_num_t Bx, var_num_t By);
133void cmd_integral(void);
134void cmd_root();
135
136void cmd_randomize(void);
137void cmd_at(void);
138void cmd_locate(void);
139void cmd_color(void);
140
141void cmd_beep(void);
142void cmd_sound(void);
143void cmd_nosound(void);
144void cmd_play_reset(void);
145void cmd_play(void);
146void cmd_pause(void);
147void cmd_delay(void);
148
149// FILE I/O
150void cmd_fopen(void);
151void cmd_fclose(void);
152void cmd_fwrite(void);
153void cmd_fread(void);
154void cmd_flineinput(void);
155void cmd_fkill(void);
156void cmd_fseek(void);
157void cmd_filecp(int mv);
158void cmd_chdir(void);
159void cmd_mkdir(void);
160void cmd_rmdir(void);
161void cmd_floadln(void);
162void cmd_fsaveln(void);
163void cmd_flock(void);
164void cmd_chmod(void);
165void cmd_dirwalk(void);
166void cmd_bputc(void);
167void cmd_bload(void);
168void cmd_bsave(void);
169void cmd_definekey(void);
170
171/**
172 * @ingroup date
173 *
174 * returns the julian-date
175 *
176 * @param d is the day
177 * @param m is the month
178 * @param y is the year
179 * @return the julian-date
180 */
181long date_julian(long d, long m, long y);
182
183/**
184 * @ingroup date
185 *
186 * formats a date string
187 *
188 * format
189 @code
190 d = day
191 dd = day, zero-leaded if < 10
192 ddd = the weekday with 3 chars
193 dddd = the weekday
194
195 m = month
196 mm = month, zero-leaded if < 10
197 mmm = the month-name with 3 chars
198 mmmm = the month-name
199
200 yy = year in 2-digits
201 yyyy = year in 4-digits
202 @endcode
203 *
204 * @param fmt the format
205 * @param buf the destination buffer
206 * @param d is the day
207 * @param m is the month
208 * @param y is the year
209 * @return the julian-date
210 */
211char *date_fmt(char *fmt, long d, long m, long y);
212
213/**
214 * @ingroup date
215 *
216 * returns the day,month,year from a string-date
217 *
218 * @param str is the string that contains the date
219 * @param d is the day
220 * @param m is the month
221 * @param y is the year
222 */
223void date_str2dmy(char *str, long *d, long *m, long *y);
224
225/**
226 * @ingroup date
227 *
228 * returns the hour,minutes,seconds from a string-time
229 *
230 * @param str is the string that contains the date
231 * @param h is the hours
232 * @param m is the minutes
233 * @param s is the seconds
234 */
235void date_str2hms(char *str, long *h, long *m, long *s);
236
237/**
238 * @ingroup date
239 *
240 * returns the day,month,year from a julian date
241 *
242 * @param j is the julian-date
243 * @param d is the day
244 * @param m is the month
245 * @param y is the year
246 */
247void date_jul2dmy(long j, long *d, long *m, long *y);
248
249/**
250 * @ingroup date
251 *
252 * returns the hour,minutes,seconds from a timer (TIMER or time_t)
253 *
254 * @param t is the seconds from midnight
255 * @param h is the hours
256 * @param m is the minutes
257 * @param s is the seconds
258 */
259void date_tim2hms(long t, long *h, long *m, long *s);
260
261#if defined(__cplusplus)
262}
263#endif
264#endif
265