@@ -191,7 +191,13 @@ int feenox_parse_line(void) {
191191 } else if (strcasecmp (token , "FUNCTION" ) == 0 ) {
192192 feenox_call (feenox_parse_function ());
193193 return FEENOX_OK ;
194-
194+
195+ ///kw+READ_DATA+desc Read data from a file (or standard output, or pipe, or queue, etc.).
196+ ///kw+PRINT+usage READ_DATA
197+ } else if (strcasecmp (token , "READ_DATA" ) == 0 ) {
198+ feenox_call (feenox_parse_read_data ());
199+ return FEENOX_OK ;
200+
195201///kw+PRINT+desc Write plain-text and/or formatted data to the standard output or into an output file.
196202///kw+PRINT+usage PRINT
197203 } else if (strcasecmp (token , "PRINT" ) == 0 ) {
@@ -1568,6 +1574,34 @@ int feenox_parse_open_close(const char *what) {
15681574 return FEENOX_OK ;
15691575}
15701576
1577+ int feenox_parse_read_data (void ) {
1578+
1579+ read_data_t * read_data = NULL ;
1580+ feenox_check_alloc (read_data = calloc (1 , sizeof (read_data_t )));
1581+
1582+ char * token = NULL ;
1583+ while ((token = feenox_get_next_token (NULL )) != NULL ) {
1584+ ///kw+READ_DATA+usage [ FILE { <file_path> | <file_id> } ]
1585+ if (strcasecmp (token , "FILE" ) == 0 || strcasecmp (token , "FILE_PATH" ) == 0 ) {
1586+ feenox_call (feenox_parser_file (& read_data -> file ));
1587+ if (read_data -> file -> mode == NULL ) {
1588+ feenox_check_alloc (read_data -> file -> mode = strdup ("r" ));
1589+ }
1590+ } else {
1591+ if ((read_data -> variable = feenox_get_variable_ptr (token )) == NULL ) {
1592+ if ((read_data -> vector = feenox_get_vector_ptr (token )) == NULL ) {
1593+ feenox_push_error_message ("unknown symbol '%s'" , token );
1594+ return FEENOX_ERROR ;
1595+ }
1596+ }
1597+
1598+ }
1599+ }
1600+
1601+ feenox_call (feenox_add_instruction (feenox_instruction_read_data , read_data ));
1602+
1603+ return FEENOX_OK ;
1604+ }
15711605int feenox_parse_print (void ) {
15721606
15731607 // I don't expect anybody to want to use this PRINT instruction through the API
0 commit comments