Getting command line arguements passed to NSIS compiled exe - nsis

How to get all the 3 command line arguements passed to my NSIS compiled exe in variables so that I can use those parameters to Exec(ute) another exe.
For example - start abc.exe "test.txt" "-1" is the command passed to my NSIS compiled exe where "abc" is exe name and "test.txt" and "-1" are the two arguements.
How to get both of them as different variables ?

Take a look at the GetOptions macro, which allows you getting the parameters when passed in a certain way. Unless you want to adapt your current commandline parameters, GetParameters might suit you better, but you'll have to parse the parameters yourself.

Related

How can I get the name of the sourced script in tcsh?

I'm looking for a way to get the name of a script that's being sourced from another script that's being executed in tcsh.
If I needed to the the name of a script being executed (not sourced), it's $0. If I need to get the name of a script that's being sourced from the command line, I can get it from $_. But when an executed script sources a script, I get an empty value for $_ in the sourced script, so I can't get the script name or pathname from that.
I'm looking for a non-manual method for getting that information.
There isn't really anything for this; source is mostly just a way to read the file and run it in the current scope.
However, it does accept arguments; from the tcsh manpage:
source [-h] name [args ...]
The shell reads and executes commands from name. The commands
are not placed on the history list. If any args are given,
they are placed in argv. (+) source commands may be nested; if
they are nested too deeply the shell may run out of file
descriptors. An error in a source at any level terminates all
nested source commands. With -h, commands are placed on the
history list instead of being executed, much like `history -L'.
So for example source file.csh file.csh will have argv[1] set to file.csh.
Another option is to simple set a variable before the source command:
set src = "file.csh" # Will be available in file.csh
source file.csh
If you can't or don't want to modify the source call then you're out of luck as far as I know. (t)csh is an old crusty shell with many awkward things, large and small, and I would generally discourage using it for scripting unless you really don't have any option available.
$_ simply gets the last commandline from history; maybe, very maybe it's possible to come up with a super-hacky solution to (ab)use the history for this in some way, but it seems to me that just typing the filename twice is a lot easier.

Bash - expected file extension on tab

I'm not sure if this is something that can be done in the Linux/Unix terminal, so I thought I'd ask.
For certain programs (unfortunately I can't think of any besides bibtex off the top of my head, which on tab auto-'extends' the .aux extension) when I'm finished typing out the file name (minus dot and extension) in front of it, I've noticed that if I hit tab it will 'auto-complete' the dot + file extension.
Is this something you can actually control somehow ? For example, if I wrote a bash script (we'll call it compile.sh) that only worked with *.tex files, I could do the following:
$ ./compile.sh nameOfProgram -- tab and autocomplete .tex extension --
Certainly it's not inherent to the bash script itself, but by some other means that recognizes I'm using said executable.
Sometimes, as is often the case while using LaTeX, there are multiple files with the same base name but different extensions in the same directory - I would like it to only accept that which has the predefined extension.
It is certainly possible to define a custom completion function for compile.sh which only matches *.tex files. Writing a good completion function is a broad task, but you can do something very simple with
# Add to your .bashrc file to enable in every shell, not just
# the current shell
complete -G '*.tex' compile.sh
which will only treat files matching *.tex as valid completions for any argument to compile.sh.

Own simple template system in vim - include file

I've read vim-wiki about dynamic templates and I want similar, simple "template-system". I've created a function:
function! Read_template(file)
execute '0r /home/zsolt/.vim/skeletons/'.a:file
%substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
%substitute#\[:READ:\]\(.\{-\}\)\[:END:\]#??????#ge
endfunction
I want to include a file from a template. The EVAL works well but how can I solve the READ function? It isn't important to eval the included file.
An example:
main.tex:
\documentclass[a4paper]{article}
....
exam.tex:
% Created [:EVAL:]strftime('%Y. %B. %d.')[:END:]
[:READ:]/path/of/main/main.tex[:READ:]
I exec Read_template("exam.tex") and want that exam.tex includes main.tex.
How can I do this?
You'll need to read the file and insert its contents. As you cannot use :read (it will read entire lines and cannot be called from within a substitution), you have to use the lower-level readfile() Vimscript function, like this:
%substitute#\[:READ:\]\(.\{-\}\)\[:END:\]#\=join(readfile(submatch(1)),"\n")/#ge
You'll have to parse each line imported and apply what needs be :
- expression substitution
- inclusion of other templates, etc. (which will mean that you'll have to remove and add lines on the fly. In the last version of mu-template template expansion engine, the expansion is done in-memory)
FYI, my work of mu-template already has this feature: http://code.google.com/p/lh-vim/wiki/muTemplate#Completely_useless_recursive_example

Nesting String Manipulations in DOS

I know you can use string manipulation in DOS like this:
echo %TIME%
echo %TIME:~0,2%
echo %TIME: =0%
The output of these three commands would be:
8:36:05.60
8
08:36:12.93
I want to know how to combine the second and third lines to get this output:
08
I can't use set to temporarily store a value because I want to use this string in a command line argument.
In pure DOS, you do not have nested statements.
Unless your application (for which the argument is) is a console app, you will not have a console to parse your environment variables (in the run box, try notepad c:\%TIME:~0,2%.txt and see what happens).
If it is a console app, then you would be able to use env vars, but no parsing, which is handled by cmd itself.
So you are bound to launch your app with a cmd.exe or a batch file and you can use all the expressions you need with SETs between.

How do I actually use the value of an argument to a Vim function?

I'm trying to write a simple Vim function that takes the name of a file as an argument and reads the contents of that file into the current document (related to this question).
Here's my first stab at it:
fun! Tpl(tplfile)
r c:\tpl\a:tplfile
endfun
That just gives me the following error:
E484: Can't open file c:\tpl\a:tplfile
How do I make the function actually use the value of the tplfile argument?
Replace the line with:
exe 'r c:\tpl\' . a:tplfile
The a:tplfile is a string variable, so to include it in a command, you have to combine the whole lot into one string (with the '.' operator) and then use exe to run the command
:help exe
On a related note (and a shameless plug), if you're trying to add templates (as implied by the post you linked to), my file templates plugin has a command AddTemplate to add a template from your vimfiles/templates directory at the current cursor location. However, the documentation is currently rather poor, so if you decide to use it and have any difficulties, feel free to drop me an email at the address on my website.

Resources