How to call Tcl command with conditional option - conditional-statements

I want to conditionally append options when calling a Tcl command. I'm using a Xilinx Tcl command synth_design as indicated in UG835 p.1042 using Tcl version 8.5.
For instance, I want to:
build a data structure that will append 0 or more of -verilog_define MACRO where -verilog_define is not a string but an option, and
pass that structure to the command in its expanded form.
Where this:
synth_design -top ${top}_top -part ${part} -verilog_define MACRO1 -verilog_define MACRO2
^-------------------------------------------^
Becomes this:
synth_design -top ${top}_top -part ${part} ???
^-^

With {*}$makro (expansion)
E.g.:
set makro {-verilog_define MACRO1 -verilog_define MACRO2}
synth_design -top ${top}_top -part ${part} {*}$makro

Related

In MS Access VBA get Number of Processor Cores

I need to get the number of processor cores available on a computer programmatically from within MS Access. As an example, the computer I work from most frequently has one processor with 6 cores. I want to grab the number '6' through VBA.
Thus far, I have found two ways to find this information through CMD. (1) I can execute the line echo %NUMBER OF PROCESSORS% and the result is 6 (simple and clean, I like it). (2) I have also tried wmic cpu get numberorcores, but the result of that prompt is as follows:
NumberOfCores
6
I intend to pipe the output to and read from the clipboard. The reason I use the clipboard is to avoid creating, reading, and deleting little text files of data. Prompt (2) works, I can successfully pipe the output to the clipboard and read it into a variable in VBA, but it's messy and I would have to parse the result to get the information I need. I would much prefer using prompt (1), but it's not working and the problem seems to be echo. I have tried using shell() and CreateObject(WScript.Shell).Run without success. The strings I have used to try to execute the echo prompt are as follows:
str = "echo %NUMBER OF PROCESSORS% | clip"
str = "cmd ""echo %NUMBER OF PROCESSORS% | clip"""
So, is there a way to successfully send an echo prompt to CMD through VBA and get a result?
Alternatively, is there a different way in VBA to get the number of cores?
TIA!
Why not keep it simple like this:
Dim result As Variant
result = Environ("NUMBER_OF_PROCESSORS")
Debug.Print "Number of processors is " & result

How to store a result to a variable in HP OpenVMS DCL?

I want to save the output of a program to a variable.
I use the following approach ,but fail.
$ PIPE RUN TEST | DEFINE/JOB VALUE #SYS$PIPE
$ x = f$logical("VALUE")
I got an error:%DCL-W-MAXPARM, too many parameters - reenter command with fewer parameters
\WORLD\
reference :
How to assign the output of a program to a variable in a DCL com script on VMS?
The usual way to do this is to write the output to a file and read from the file and put that into a DCL symbol (or logical). Although not obvious, you can do this with the PIPE command was well:
$ pipe r 2words
hello world
$ pipe r 2words |(read sys$pipe line ; line=""""+line+"""" ; def/job value &line )
$ sh log value
"VALUE" = "hello world" (LNM$JOB_85AB4440)
$
IF you are able to change the program, add some code to it to write the required values into symbols or logicals (see LIB$ routines)
If you can modify the program, using LIB$SET_SYMBOL in the program defines a DCL symbol (what you are calling a variable) for DCL. That's the cleanest way to do this. If it really needs to be a logical, then there are system calls that define logicals.

How can I start emacsclient then eval a lisp expression but with emacsclient window opened?

Example: emacsclient --socket-name ~/.emacs.d/server/server -eval "(message \"argsFromCommandLine\")"
If I execute command above, the emacsclient will print ok then just exit.
I want to eval a lisp expression after emacsclient start but with new emacsclient window opened.
Actually, I want to execute this command from Intellij with external tools.
emacsclient --socket-name ~/.emacs.d/server/server -eval "(magit-status \"/Users/louxiu/projects/magit-test-project\")", jump from one source file of magit-test-project to its magit-status-mode in emacsclient.
Thanks
Passing -c/--create-frame to emacsclient should do the trick.
If I run emacsclient -c --eval "(magit-status \"/path/to/project\")" I end up with a new emacs frame in a magit-status buffer for the expected project.

How to write a ping to a text file using VBS

If I am using VBS to run some CMD commands, in this example ping, how could I write the command to a text file using VBS not DOS?
Set objCmdTest = WScript.CreateObject ("WScript.Shell")
Set Output = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\vbs\test.txt",8,true)
Output.WriteLine (objCmdTest.run ("ping failboat"))
Output.WriteLine (objCmdTest.run ("ping 8.8.8.8"))
So this is what I'm working with however what happens is; The script runs, the file is made, 2 command prompts open to run the pings and finally the text inside the file reads:
0
0
When I'd much prefer it to have the ping output.
FYI: Please don't offer suggestions that require me to use DOS for the writing, I'd like to see how VBS can do what I need for multiple reasons, thanks!
The instruction Output.WriteLine (objCmdTest.run ("ping failboat")) will write the return value of the Run method to the output file. If you want to append the command output to an output file you have to either redirect the output in the command:
objCmdTest.run "%COMSPEC% /c ping failboat >>C:\vbs\test.txt", 0, True
or use Exec instead of Run:
Set ping = objCmdTest.Exec("ping failboat")
Do While ping.Status = 0
WScript.Sleep 100
Loop
Output.WriteLine ping.StdOut.ReadAll
WScript.Shell's run method returns the process's exit code. In order to get access to an application's output, you need to use the exec method instead, and use the object that returns to get access to the process's standard output through its StdOut property.

How to pipe visually selected text to a UNIX command and append output to current buffer in Vim

Using Vim, I'm trying to pipe text selected in visual mode to a UNIX command and have the output appended to the end of the current file. For example, say we have a SQL command such as:
SELECT * FROM mytable;
I want to do something like the following:
<ESC>
V " select text
:'<,'>!mysql -uuser -ppass mydb
But instead of having the output overwrite the currently selected text, I would like to have the output appended to the end of the file. You probably see where this is going. I'm working on using Vim as a simple SQL editor. That way, I don't have to leave Vim to edit, tweak, test SQL code.
How about copying the selected text to the end of the file, select the copy and run the command? If you do not want to repeat the same commands over and over again, you can record the sequence by using q or add a new command. I have tried the latter as follows:
:com -range C <line1>,<line2>yank | $ | put | .,$ !rev
With it you can select some lines and then type :C. This will first yank the selection, then go to the end of the file, paste the yanked text and run the command (rev in this case) over the new text.
If you prefer more programmatic approach, you can have
:call append(line("$"), system("command", GetSelectedText()))
where GetSelectedText is the reusable function:
func! GetSelectedText()
normal gv"xy
let result = getreg("x")
normal gv
return result
endfunc
Try
:r | YourCommand
For example:
:r ! echo foo
adds foo to your buffer.