Difference between async and sync in octave? - octave

I was having issues with the editor in octave and posted an question before: Octave output buffer completely messed up on OS X. How to fix?
The way how I fixed the question is using edit mode sync instead of the default async. However, I don't really understand what's the difference between async and sync here? And why when using async the keyboard was sending signals to both octave and the editor so that the output buffer gets messed up? If possible, can we use async mode for macbook? (Since everything works fine on my linux computer)

According to the help text of `edit()':
[...] async mode (editor is started in the background and Octave continues) or sync mode (Octave waits until the editor exits). [...] (see also "system").
It basically defines what happens after starting the other process (emacs in your case). Think how edit() was designed to be used. You are at the Octave prompt and use it to open a function file in your text editor. You make changes to the file while still using the Octave prompt. That's async mode.
However, your text editor does not a have a GUI. When you start emacs, you use it on the same terminal window where you called it from. Because you have it set to async, you end up with both emacs and Octave interactive in the same terminal. Set it to sync means that until you exit emacs, Octave is just waiting so it doesn't mess up with what's being displayed.
You can:
use a text editor with a GUI;
change your EDITOR command to open a new terminal, and start your CLI emacs there. For example, if you are using gnome-terminal, you can set it to gnome-terminal -e emacs %s;
change mode to sync.

Related

Simple html to pdf conversion commandline tool for automated file creation

I have a system that automatically creates and saves documents as html. For further storage they ought to be pdfs though.
I want to avoid having to do it manually so my preferred solution would be a small executable that I can call via command line, feed it with a source and output path (and ideally further parameters) and then let it do its magic. Something in concept like this:
exampleConverter.exe "C:\source\document1.html" "C:\convertedPDFs\document1.pdf"
No UI whatsoever, no human input, no popping up and closing console.
I looked through several options, but common problems I encountered were
the software not being free for commercial use
It just being a library of code, not a ready-to-go executable / code-base you just need to compile into one
The tool needing to get installed instead of being 'portable'
I'd like to avoid having to implement any modern libraries myself, partially for simple time concearns, partially because internally our code runs in a less than modern IE & VBS context so I for see compatibility problems.
Simply triggering a precompiled executable through a generic command line inerface that I can trigger from vbs seems like the perfect solution here.
Your Windows OS program code is almost there, why not reverse input and output (makes the task easier later), with a switch or two. you can embellish that with your for /? loop to run through the current working folder, just like any other program.
Your pseudo code
exampleConverter.exe --print-to-pdf="C:\convertedPDFs\document1.pdf" --headless "C:\source\document1.html"
Working Windows native code
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --print-to-pdf="%CD%\out\document1.pdf" --headless "%CD%\in\document1.html"
Other options are available
learn.microsoft.com suggest this working snippet to run edge with parameters
wscript vbsEdge.vbs
Dim shell
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "msedge https://www.google.com --hide-scrollbars --content-shell-hide-toolbar"
So just combine the program methods. However, you need to sort out your own arguments.
For greater control then you need to step-up to heavier custom isations https://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/ etc.

Octave pop up message

I am running Octave 4.4.1 on MacOs Catalina 10.15.7. For some weeks I have been having this message poping up when a code is running: "
It seems that [name of script] has been modified by another application. DO you want to reload it?
I click Yes each time it pops up, but when the code is running, it just keeps coming back, and sometimes Octave becomes unresponsive although the script has finished running
All I could find on the internet were either some old posts with answers about outdated Octave versions, or very complicated stuff that I would not be able to implement.
Any one knows why this happens, and what to do about it?
thanks a lot
This message is exclusive to the GUI version of Octave, and it comes up if you have a file open for editing in the Octave GUI Editor window, and the file's contents change due to a process unrelated to the Octave Editor.
E.g. you may also be editing the file on an external text editor at the same time? Or your script may be copying / generating a new file under the same name as a file that you've got open in the editor, effectively overwriting the now-out-of-date version that's still being displayed in the Octave Editor?
Octave gives you this warning to prevent you from 'saving' in your editor, and therefore undoing any changes that had been made by the external process in the meantime.

"pause" is not pausing the execution of script in Octave 5.1.0 in Windows 10

pause should stop the execution until something happens. But in my case where i have OCTAVE 5.1.0 on OS WINDOWS 10 is not doing its work properly. It does ignore all pause statements in script and execute the whole file.
I am running this program in my installed octave application in command window with GUI.
What may be the problem?
I have tried pause with function brackets
pause();and without function brackets pause; but still problem remains same.
%do something
plotData(X, y);
fprintf('Press enter to continue.');
pause;
%do something
plotData(X, y);
I except that script will first plot data and will stop execution till key is pressed to enable me to analyze data then after key press it would plot another plot with processed data.
But it just plot both plots in fast manner that i could not see it.
There are few bugs related to pause that have been introduced since version 5.1 and seem that recently have been fixed. It will be available in the next version. You can try alternative functions like kbhit or switch to a previous version.

Command to send signals to waveform in SimVision

Is there a (Tcl-)command I can use to send signals to waveform in SimVision?
Of course You can rightclick them and then select "Send to WaveForm Window", but to do that each time you start a simulation will be a pain.
In Modelsim you can easily use "add wave" in a dofile (tcl file), but strange if there would be no way to do this with ncsim...
When you have your waveform window set up the way you like (with all desired signals), you can go to File -> Save Command Script . This will save your window setup as a tcl file. You can look in there to see what the tcl commands are if you are interested in doing it manually.
To restore the waveform window next time, simply go to File -> Source Command Script and select the file you had saved previously.
Note: I'm using SimVision 12.10
a minimal working example I've come up with:
window new WaveWindow -name "Waveform"
waveform using {Waveform}
waveform add -signals tb_foo_u.module_bar_u.signal_xyz
You can type that in the SimVision console (if you're using irun in GUI mode). Tested in 15.20. Those are simulator-specific commands.
If you want it to be done automatically # irun startup (using .tcl file), examine the results of running commands from the other answer, then tailor it to your needs.
For the full, verbose description of waveform instruction, refer to the documentation provided with the simulator under SimVision Tcl Commands / waveform.

Open a Tcl file with Wish Application

I'm running Windows 8. I have a file named "test.tcl".
If I open a shell, type "wish", then 2 windows open. In one of them, I can type Tcl code and open the file test.tcl. If I open this file, its code is executed.
If I double click on test.tcl to open the file with "Wish Application", then 1 blank window open, and nothing happens.
Do you know why please?
On Windows, Wish is built as a GUI-only application; it has no real standard output available. Tk fakes one for you though; just put this in your script to show the fake console:
console show
The fake console shows up by default when you launch without a script file, but launching with a script file doesn't show it (so your script file can implement an application, of course).
This can catch people out when they produce a lot of output on stdout. Tk may well be keeping it all faithfully just in case the code does console show later on, though it looks and smells a lot like a memory leak if you're not prepared for it…