NSIS SelectFileDialog filter not being applied - nsis

I have used the following line in an NSIS script:
nsDialogs::SelectFileDialog open "C:\temp.rar" "*.rar"
When I run the resultant installer (in Windows 10) the file dialog opens to C: as it should, temp.rar shows in the File name field, and *.rar shows in the filter dropdown. However the filter is not being applied to the file list. That is, all filetypes are still visible, despite *.rar being the only entry in the filter dropdown.
Does anyone have any idea what might be causing this or how to fix it?

The documentation is unfortunately not clear on this but it uses the same format as the GetOpenFileName function in Windows; the filter is a list of pairs; display string and DOS filter:
nsDialogs::SelectFileDialog open "C:\temp.rar" "*.rar|*.rar"
Pop $0
nsDialogs::SelectFileDialog open "C:\temp.rar" ".rar files|*.rar|All Files|*.*"
Pop $0
Keep in mind that the filter is only there to help the user but the user can type in any file name they want even if it does not match the active filter.

Related

Zenity: File selection dialog - case insensitive filetype filtering?

I was hoping some kind person who is more intelligent than me could help.
I am writing a small script to call various programs in the background and do various things so a list of PDF files that the user selects, using Zenity as a GUI of sorts.
Everything is working so far, but I have hit a roadblock:
The PDF files that the user selects might have different cases in their file extensions, e.g. .pdf of .PDF or even .Pdf
I would like the user to be able to select the PDF files they need, and only show PDF files, but since the sources of these files are unknown, it is possible that their extensions are in who-knows-what case, upper, lower mixed, who knows...
Is there a way to call a Zenity file selection dialog and filter all PDF files, regardless of the case (upper/lower) of their extension?
I have the following code so far:
zenity --file-selection --multiple --file-filter='*.pdf | *.Pdf |*.PDF'
BUT this is NOT a good solution as the person will have to select each option separately. I would like them ALL to be shown, no matter the case of the letters in the extension.
Thanks again for any kind help.,
I just had the same problem and tinkered this solution which works for me.
Maybe you have some use for it as well:
zenity --file-selection --file-filter=*[PpDdFf]
have fun!

Opening a random file only knowing the extension name anywhere on the computer in python [duplicate]

I want to do the following:
Save numeric data in a CSV-like formatting, with a ".foo" extension;
Associate the ".foo" file extension with some python script, which in turns opens the .foo file, reads its content, and plots something with a plotting library (matplotlib most probably).
The use-case would be: double-click the file, and its respective plot pops up right away.
I wonder how I should write a python script in order to do that.
Besides, the windows "open with" dialog only allows me to choose executables (*.exe). If I choose "fooOpener.py", it doesn't work.
This isn't really a programming question, but what you need to do is to figure out how to get the Python executable into the registry key that opens your data file.
For example, I created a little Python script called opener.py that looks like this:
import sys
print(sys.argv)
input()
Then I created a testfile.foo and used the "change" button in that file's property dialog to choose opener.py. (You can do this if you click Browse and change the Open With dialog's file filter to "All Files".)
Of course this didn't work (as you noticed). So I opened regedit and searched for opener.py and found it at the following registry key:
HKEY_CURRENT_USER\Software\Classes\Applications\opener.py\shell\open\command
The default value of this key was "C:\opener.py" %1. I changed it to python "C:\opener.py" %1. It worked!
Long story short, to do this properly you need to custom-edit the registry. Actually setting up the file association is more complex than just editing that one key (you have to also indicate that .foo is associated with opener.py).
An alternative approach would be to turn your Python script into a standalone executable using one of the several tools available for that purpose, or write a small executable in C that launches the script.
press the windows key
type cmd
right click the result and choose "run as administrator"
assoc .foo=foofile
ftype foofile="C:\Users\<user>\AppData\Local\Programs\Python\PYTHON~1\python.exe" "C:\<whatever>\fooOpener.py" "%1" %*
Use pythonw.exe if it's a .pyw file (to prevent a cmd window from spawning).
If you want to use an existing file type, you can find its alias by not assigning anything. For example, assoc .txt returns .txt=txtfile.
instead of editing registry, you can create batch file
opener.cmd
with content
python "C:\<whatever>\fooOpener.py" %1
and associate extension with this file.
It works!

Sublime Text 3 specific file type settings only has JSON file settings. How to create new?

I'm trying to create a syntax specific settings for file types in ST3. As per the documentation I am supposed to find what I need in
Sublime Text>Preferences>Settings - More>Syntax Specific - User
However, when I click that I only get JSON.sublime-settings file. What if I want some other settings file?
The settings file that opens when you select Prefereces > Settings - Syntax Specific is sensitive to the type of file that you're currently editing. So, if you happen to be in a JSON file when you invoke the menu command, you get the file for settings specific to JSON.
In order to get at the setting specific to a different syntax, open a file of that type first, or create an empty buffer and set the syntax to the desired language via View > Syntax from the menu, the command palette, or the menu that pops up when you click the file type in the right side of the status bar (where it will say Plain Text).
The file that you actually want to save is SyntaxName.sublime-settings in your User package, e.g. Python.sublime-settings for Python, etc. However to forestall any problems with the filename (like incorrect case or spelling) it's generally better to do it as above instead, particularly since the name of the syntax can sometimes be non-obvious.

PowerGrep Search and Replace: "cannot make replacements using read-only converters"

I get an error on PowerGrep software when I try to Replace the content of some files: "cannot make replacements using read-only converters"
What can I do? Can anyone help me a little bit?
I find the solution:
In the left menu, on File formats to convert to plain text, you have to choose from that combo "Writable proprietary formats".
Then, press the section [...] and add NEW (format). In my case, I add .txt. Click ok. And then run "REPLACE"

Taking numbers from csv file using labviiew

My program should take all numbers from CSV file put them to array and have some problems.
Have can I take some char of string? Here my program:
https://drive.google.com/file/d/0B7eFfQuRzPgAX3o3WmJIb2dzMFU/view?usp=sharing
Example of csv fie:
1, 2, 3, 4
6, 1, 2, 10
Your code is overly complicated. You can load the file using the Read from Spreadsheet file function and simply create a 2D array of the output.
The Read from Spreadsheet function is polymorphic. That means you can select what data type it uses. Right-click on the node and select 'Visible Items' and then 'Polymorphic VI Selector'.
Change the pull-down on the bottom of the node to String, and then create a string constant and set it's value to , (comma).
please consider using deliminator input on read from spreadsheet VI.
Please check attached
The read from spreadsheet file vi is the simplest solution as answered previously. One thing to note about using that function though is that it internally uses the labview error handler with the "Stop" or "Continue" dialog box popup. I've run into the problem where the user cancels out of the file dialog, then sees the error handler dialog box, presses "Stop" and gets confused why the program behaves unexpectedly afterwards.
To prevent this, test the file path using the "File/Directory Info" vi and "Check if File or Folder exists.vi". Put the Read from spreadsheet file in case structure which only runs when the path is not a directory and exists. I tried to attach a snippet to show this, but do not have enough points.

Resources