Change input of flex from stdin to file? - flex-lexer

So I've been using flex for awhile, and the entire time I have been feeding it input directly from the terminal. Now I want to feed it a file. An adhoc solution I came up with was to use dup to change the stdin to a file, but am wondering if there's a way built into flex to do the same thing?

I figured it out, you can set yyin to a c file
yyin = fopen("file.txt" "r");

Related

How to print out ASCII to a separate file.

I am trying to print data using
*EL PRINT
to a separate file other that jobname.dat file.
Is there any way to do this?
PS: I know how to export the data from the odb file.
Thanks
As far as I know you can't reroute that kind of input-file keyword output request to a different file. I've listed some alternatives below:
As you mention, you can script it using the Abaqus/Python API.
You can manually print results to a file of your choosing from the Viewer.
You can access the results file for postprocessing using a Fortran or C++ program (search for ABQMAIN).
You can access results and write them to a file of your choosing during the analysis using the Fortran subroutine URDFIL.

how to overwrite, or delete the file, used by writefile() calls?

I use the following to save screen output to a file
writefile("file.txt"),
tex(expression),
closefile()
The above sends the output of the tex() to the file automatically. which is all and well and what I want. (side-point: It also sends an annoying NIL line each time to the file, which I had to parse put later).
Now, when running the above code again, the file is appended to, which is not what I want. I want to either overwrite the file each time, or if there is a way to delete the file, so I can call delete on it before.
I looked at help and not able to find a command to delete a file, and I also see no option to tell writefile() to overwrite the file?
Is there an option or way around this? I am on windows 7, Maxima version: 5.36.1
Lisp: SBCL 1.2.7
I guess you are trying to capture the output of tex into a file. If so, here are a couple of other ways to do it:
tex (expr, destination);
where destination is either a file name (which is appended) or a stream, as created by opena or openw and closed by close. By the way, destination could be false, in which case tex returns a string.
with_stdout (destination, tex (expr));
where again destination is either a file name (which is appended or clobbered, as determined by the global flag file_output_append) or a stream.
with_stdout could be useful if you want to mix in some output not generated by tex, e.g., print("% some commentary");.

Lua : create the simplest possible program that is still considered "correct."

i want to know that how can we create simplest possible program that is still considered "correct" as programmability.
Example :
In python a blank .py file is a simple possible program that is programmability correct.
Same in Lua: the empty program is correct.

gnuplot with iOS

Does anyone here have experiences of using gnuplot with iOS? I want to develop a scientific computing app on iOS devices and want to use gnuplot as the plotting engine. Are there any good tutorials from which I can start with?
I have the same general question, a quick google search led me to the following app, which seems to use gnuplot.
https://apps.apple.com/us/app/icas-workstation-class-scientific/id394637176
I followed the trail to their website:
http://alsoftiphone.com/iCAS/
I contacted them about it, and I will follow up if/when I get a response.
The response:
Hello,
As you've aptly pointed out, there are some complications when embedding gnuplot in an app, particularly if you intend to dynamically create and dispose of it. That is, gnuplot (as of v4.4.0 which is what I used) doesn't explicitly release some memory that it allocates presumably because it assumes that it will be released when it is quit, which would be the case when it is used as a standalone application. This will of course result in memory leaks. Similarly, gnuplot doesn't explicitly close its output file descriptor (which is set to stdout as far as I know). And it also doesn't clear multiplot mode when the main function exits which is problematic because the next time you call gnuplot in an embedded situation, some global variables will reflect multiplot mode if called thereafter.
Fortunately for you, I've already identified them so you won't have to hunt them down like I did. Unfortunately, though, I didn't create a library for my projects but here are the relevant changes that you'll need to make to the gnuplot source code.
plot.c line #615, at the end of the else block for the "if (interactive && term != 0)" conditional block of the main() function (which you will also want to change to some appropriate entry function name):
// Free replot_line
if (replot_line != NULL)
{
free(replot_line);
replot_line = NULL;
}
plot.c line #680, before "return exit_status" at the end of the main() function:
// Free replot_line if it was allocated
if (replot_line != NULL)
free(replot_line);
// Clear multiplot mode, if it was active
if (multiplot)
term_end_multiplot();
// Close current file
if (gpoutfile)
fclose(gpoutfile);
The other issue is that gnuplot is written to use stdin and stdout so for my apps I replaced them with my own appropriate file descriptors to serve as the interface to/from gnuplot. That will be implementation specific, so I won't list my own particular changes but you'll basically need to look through the gnuplot source for instances of stdin and stdout and replace them as appropriate for your needs.
You'll also want to #define NO_GIH in config.h.
Other than that, you'll probably need to hard code the appropriate gnuplot terminal type for your app (I used SVG in my apps).
I hope this helps.
Best Regards,
Antonio Lagana

How can I print a file from the command line?

Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
Since it is a .docx-file Microsoft Word is probably the best program to do the task.
I would have a look at the [command line arguments] to Word:
Have a look at the following switches:
/q, /n, /mFilePrintDefault and /mFileExit
(/q and /n explained in the page above, and /mXxxx refers to macros. Have a look att google.)
Example:
WINWORD.EXE your_document.docx /mFilePrintDefault /mFileExit /q /n
The following page seems to explain how to convert it to PDF.
What you are looking for is called "headless start" of the program which needs to print.
I know for sure that OpenOffice can do this.
Basically, you need to start it and invoke a macro which will do the printing. Even more, you can print to a PDF, HTML, or anything else that Oo supports.
This negates the need for install of Microsoft Word and the cost of license, because OpenOffice is free.
If you are looking only for .docx silent printing then [aioobe] answer is the best. If you want a more generic silent print program that runs on Windows, use powershell or .NET and use the print verb. http://www.eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx provides an example.
Hope this helps, if so +1 please :)
You might be interested in DocTo which will convert a word document to another file format, including pdf and XPS but does require Word on the machine.
For example
Docto -f "c:\docs\mydocument.docx" -o "c:\output" -t wdFormatPDF
Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.

Resources