I am very new to Clojure and just installed CounterClockWise and created my first Clojure project in Eclipse.
However I need to create another .clj file aside from the provided core clojure file.
How do I do this?
There is a New File command in Eclipse which can be used to create an empty file of any type. If you create a file and name it something.clj you have a new Clojure file.
The New File command can be accessed through the menus like this:
File menu > New > Other... > General > File
Or with a keyboard shortcut: Press Ctrl+N to open the New wizard, then type file in the search box to filter out the file creation command.
This technique is very useful generally to create various new things.
Maybe there also is a New Clojure File command (or something like that) in the list of things in the New wizard.
Not an Eclipse answer, but I sometimes have a similar issue with IDEA. The simplest answer (on linux) is to just do touch src/myproj/newfile.clj or similar, to create an empty file with the desired name and location. The IDE can then easily open the (pre-existing) file for further editing.
A similar strategy is to open the file for the 1st time in another editor like vi, emacs, or whatever.
A related issue on IDEA is that it uses the namespace declaration (ns xyz ...) to label the editor tab, not the actual file name. If you are renaming files you cannot actually see the new name easily until you change the ns declaration, which is very confusing. In these cases, I will also fall back to using gvim to edit the ns declaration, or any other low-level or detailed edits.
Related
I'm looking to have a way of opening files in my Qt app within a context menu, like opening any image file in Photos or Photoshop. Mostly what I'm finding though is either possibly out of date ways of doing it, like way earlier versions of Qt, or incomplete posts about doing something with shell extensions, but it's mostly adding an icon to custom file extensions in explorer, not the opening actions. Or ways of doing it with the general Windows API I think, which I don't know how this would "connect" with my Qt app to open a file in it, and the windows api is very scary to me.
Is the way of doing now with a newly added module in Qt using C++, or maybe something with an "installscript.qs" file, or "package.xml"? I've never seen or used a .qs file before. Basically, I'm not sure where to look for how to do it the most updated and easiest way.
The screenshot below is an example of the functionality im talking about. With my Qt app not being open, a file of the types I want (.jpg, .png, .gif, etc) is right clicked, and I can click like "Edit with MyQtAppName", or open the "Open with" sub menu and click "MyQtAppName". Then ultimately this files full path would be passed into my Qt app as a string somehow. I don't know how this pass of the path string happens yet, but yeah. Any help appreciated.
I would like to know how do I open a file with a specific extension
Inside the downloads folder. I try this:
set downloads to "~/Downloads"
set fileExtension to ("pkg")
open every file of downloads whose name extension is fileExtension
I know I could use:
do shell script "open ~/Downloads/blabla.pkg"
and this would work fine but with every update the file changes its name and this would not be interesting to me.
thanks advance!
While do shell script can use a string for a path, AppleScript itself has limited file handling abilities, so you need to tell it to use something that does, such as the Finder or System Events. A file specifier (such as alias, file, or application scripting terms such as folder or disk item) also needs to be used to differentiate a file item from a regular string (such as a POSIX path). Depending on the application used, there may be other differences from the shell, such as tilde expansion, so the StandardAdditions scripting addition provides paths to common locations:
set fileExtension to ("pkg")
tell application "System Events"
repeat with anItem in (get every file of (path to downloads folder) whose name extension is fileExtension)
open anItem
end repeat
end tell
Also note that using the filter reference form “whose” only works with application objects, and not regular lists or records. AppleScriptObjC also has access to Cocoa methods, so you can use the NSWorkSpace or NSFileManager classes, although going that route tends to get a bit more verbose.
I can't seem to find the answer, how do you create a new file in Ocaml? Do you edit your file in the terminal? Where does the source code appear?
I think you're asking how to write code in OCaml, i.e., how to create an OCaml source file. (This isn't completely clear. You could be asking how to write OCaml code that creates a file.)
The details of creating OCaml source depend on your development environment, not on the language itself. So there is no one answer.
The general answer is that you can use any tool you like that knows how to create a text file. If you like working from the command line (as I do) you can work in a terminal environment and run some kind of vintage text editor from the last millennium (as I do). If you like a GUI environment, you can run some kind of "programmer's editor" from the current millennium, or really any kind of editor that creates basic utf-8 files (or even ASCII files).
Generally the editor will have to be told where to store the files that you edit. You would probably want to make some kind of folder for the project and make sure you store the text files in there.
I hope this helps! If you have any programmers nearby, they can probably get you started a lot faster than asking on StackOverflow.
I start Microsoft Visual Studio 2010. I chose to start a new project on the Welcome Page. Ofcourse my preferred language is Visual C++ and I'm chosing to begin a Windows Forms Application. I give up a name like Calculator for this one. I do not touch the other options on this dialog. The project gets created and a new Form1.h is automatically added to the project, and a Form1.resX is also added. Because 'Form1' is useless to me, I'dd like to rename it to something more VB6 style, like "frmMain.h". So I right click the Form and simply chose "Rename". After accepting my new name, the necessary changes seem to be occuring. first impression But now, when I try to build this project, It gives a BUILD FAILED. When I look into my files.. Form1 is still mentioned..
So my question is: How do you actually/OFFICIALLY rename Forms?
I've been reading a lot about this and mostly the answer is to delete the form, and re add a new with the right name.. I've heard also that VS asks to rename all references to it, but that doesn't show up to me. Some other people say, you have to use the quick replace function, and rename all references to this class and its file.. This is not a good way to me.. Or is it really the standard procedure?
I have programming experience in C++ and I know about classes and polymorfism and so on. But this is one of the simplest things that keeps me annoying!
You are using VC++.NET to create .NET applications (Windows Form in your case). I must warn you that VS is not very friendly for VC (refactoring, renaming, and little intellisense).
In this case, you renamed the form which will make VS also rename the Form1.resX, but it will not rename the class. It will do it if in C# or VB.NET. Just open the .h file and rename the class itself to match the name of the file.
You also need to update the main .cpp file where "main" resides, and update the Application::Run(gcnew Form1()); in there as well include the "#include".
A solution replace will work (Ctrl+Shift+H), but be careful with this.
click on the form -> properties -> text (usually named as Form1) -> change it.
Apparently this supposed to be possible. For example opening and operating on a file with NOTEPAD, or HxD. But aren't they all text files...how would one specify which text editor to open the file and operate on the file with using the WINDOWS API. It is certainly not in "CreateFile".
Hopefully I'm understanding your question... The easiest way to do this is to launch the desired editor and pass the filename as an argument, rather than "invoking" the file (which will launch the default program associated with the file type).
For example, notepad.exe mytextfile.txt or gvim.exe mytextfile.txt.
If the editor is not on your %PATH%, you'll need to use a full path file name.
What are you trying to do, exactly? You could:
Maintain a list of editors that you expect to be installed and have entries for in the system's PATH (bad idea)
Have an editor/editors that you want to use, query the Windows registry to find the installation path of the editors (using RegGetValue), and launch the editor with CreateProcess) (a little better idea)
Query the registry to get the default editor for a given file type and then launch that editor using CreateProcess. (best idea)
But it all depends on what your goal is really.
Edit based on requirements
So, just so we're on the same page, from C++, you want to:
Take a command line parameter to your C++ application (filename)
Open that file in an arbitrary editor
Detect when the user has made changes to that file
Operate on the file contents
Is that correct?
If so, you could:
Use Boost libs to compute a CRC for the current data in the file
Launch an editor using one of the methods I initially described
Stick in a tight loop and sleep so you don't chew up resources while the initially computed CRC matches one calculated every iteration of the loop
Of course, there are all kinds of issues that you'd have to deal with (that's just a super simple way of describing the algorithm I might use), such as:
What happens if the user doesn't change the file?
What happens if the file isn't found?
I'm sure that there are a number of different methods of doing this, but this is the easiest method that I can think of at the moment (while still being able to be fairly certain of the changes).
Disclaimer: I haven't implemented something like this, so I might be completely off base ;)
Are you looking for the ShellExecute() or ShellExecuteEx() APIs on Windows? They'll launch whatever program is registered for a file (generally based on the filename extention).