On the control panel menu, go to "File" / "New File" and select the desired language. Languages that have not been used recently can be found under "Other".
You can also select "File" / "Open File", go to the desired directory, and type in a file name that does not exist. jGRASP will then ask if it should be created. You can force the selection of language using the "Language" combo box. If this is set to "Default", the language will be selected based on the file extension.
If jGRASP is on your system's PATH, from the command line you can go to the desired directory and type "jgrasp some_file". If some_file does not exist, jGRASP will ask if it should be created. The language will be selected based on the file extension.
To change the language for a file once it is created, see the next item.
To change the language of a file, select "Edit" / "Compiler Settings" / "File" on the CSD window menu. Choose the "Compiler" tab on the settings dialog. Select the desired language from the "Language" combo box. Once a language is selected, jGRASP will remember this setting. Also, the icons in file dialogs and in the browse window will reflect this setting.
The "File" / "Recent Files" menu on the control panel is an easy way to open recently used files.
Another convenient way to open a file is to use the browse window. You can double click on a file to open it in text mode. If the file is HTML and you want to edit it rather than opening it in the documentation viewer, you can drag it from the file browser to the virtual desktop. This will also open it in text mode. If you need to open the file in binary mode (show and edit all line terminator characters other than newlines), right click on the file and select "Edit Binary". All of these methods will choose a language based on the file extension if the file has not previously been opened in jGRASP, otherwise it will choose the last language used for the file.
On most systems, you can drag files from file browsers or other applications onto the jGRASP desktop and they will open in text mode.
If jGRASP is on your system's PATH, from the command line you can go to the desired directory and type "jgrasp some_file". This will open some_file in text mode.
From the control panel menu, "File" / "Open File" will bring up an open file dialog. This will allow you to open files in text or binary mode and with a specified or default language.
If the file is in an open project, you can double click on the file in the project window or if a UML window is open, double click on the class (or one of the classes) in the diagram.
Hit Ctrl-S or "File" / "Save" in the CSD window. If the file is unnamed, you will be prompted for a name.
Hit Ctrl-D or "File" / "Backup As" to save a backup of the file without changing the file you are editing.
Hitting "File" / "Save As" in the CSD window will bring up a "Save As" dialog. This dialog allows you to change the line terminator type for text files.
For languages such as Java with run-time linking, "Compiler" / "Compile" will compile the file, and in the case of Java, out-of-date dependencies (note that dependencies are compiled, not dependents). For languages such as C++ with build-time linking, "Compiler" / "Compile and Link" will create the executable for a single-file program, while "Compile" will compile the file only. jGRASP does not provide a "build" function for multiple file programs in languages with build-time linking. For such programs, you should write a makefile or other build script. For most jGRASP compiler environments, "Compiler" / "Make" will call the "make" command in the directory containing the file.
For Java projects, if a UML window is open, "Compiler" / "Compile" all from the UML window will recompile all files in the project.
Typically, "Run" / "Run" from the CSD window will run the program. For some languages, such as Java, you can specify a main file for a project using "Run" / "Workspace's Main File". After that, you can use "Run" / "Run" from any file in the project, not just the "main" file.
To pass command line arguments, click "Run" / "Run Arguments". A toolbar will appear in which you can specify the arguments.
To set command line arguments for the whole project, or in a more permanent way, go to "Edit" / "Compiler Settings" / "Project" (the file must be in a project), select the "Flags / Args / Main" tab, click off the default box for "FLAGS or ARGS" and "Run", and enter the arguments. Note that the "Run Arguments" toolbar will override this setting. The "FLAGS2 or ARGS2" flags are used in some languages, such as Java, to send arguments to the runtime system rather than the program itself. In Java for example, you could set "FLAGS2 or ARGS2" X "Run" to -Xmx500m to set the maximum size of the memory allocation pool to 500MB.
On Windows, click "Run" / "Run in MSDOS Window". After that, programs will run in a DOS window. Currently, Java programs can not be debugged (using the jGRASP debugger) with I/O from/to a DOS window, but this will be implemented in the future.
From the control panel menu, "Project" / "New Project" will bring up a "new project" dialog. From there you choose the project filename. If "Add Files Now" is checked in the dialog, an "add files" dialog will pop up after you create the project. If the project is to be a Java project and "Open UML Window" is checked, a new UML diagram will be created for the project.
Files can be added with either relative or absolute paths. Files in the project that "belong to the project" should be added with relative paths, so that the project file and member files can all be moved or copied. If some file is at a fixed position on the system, add it to the project with an absolute path so that it can still be found when the rest of the project is moved or copied.
The simplest way to add files to a project is to drag them from the browse window to the project window. The project into which the file(s) will be dropped is highlighted as you drag over the project window. The files will be added with relative paths. On most systems, files can also be dragged from an external file browser or other application to the jGRASP project window.
Selecting "Add Files" from the project window context menu for the desired project will bring up an "add files" dialog.
For the active project, selecting "Project" / "Active Project" / "Add Files" on the control panel menu will bring up an "add files" dialog. You can also add files to the active project using "Add to Active Project" on the browse window context menu, or "File" / "Add to Active Project" on the CSD window menu.
If a UML window is open for the project, you can drag files into it from the browse window, or on most systems, from an external file browser or other application.
In the project window, select all the files you want removed (from one or more projects) and either bring up the context menu and select "Remove From Project(s)" or select "Project" / "Remove Selected Files From Project(s)" from the control panel menu.
For the active project, selecting "Project" / "Active Project" / "Close" on the control panel menu will close it.
Select the active project from among the open project using the "Make Active" menu item on the project window context menu for the desired project, or by using the "Project" / "Set Active Project" menu on the control panel.
The "Project" / "Recent Projects" menu is an easy way to open recently used projects.
Double clicking on the project in the browse window will open it.
"Project" / "Open Project" from the control panel menu will bring up a dialog that allows you to select and open a project.
Select "Close" from the project window context menu for the project you want to close.
To close the active project, select "Project" / "Active Project" / "Close" on the control panel menu. The first remaining project (if there are any) in the project window will be made active.
F9 and Shift-F9 or Find and Shift-Find will search forward and backward for the selected text in a CSD window. This works across CSD windows - the selected text does not have to be in the window being searched.
In the "Additional Doc. Command Flags" box of the
documentation dialog, enter "-link" followed by the URL of the
Java API. For example:
local file: -link "file:///C:/j2sdk1.4.0/docs/api"
Sun website: -link "http://java.sun.com/j2se/1.4/docs/api"
The Java API documentation can be downloaded from
http://java.sun.com.
Default extensions can be set for each workspace. Select "Edit" / "Compiler Settings" / "Workspace" on a CSD window, or "Settings" / "Compiler Settings" / "Workspace" from the control panel. Select "C" or "C++" from the "Language" combo box, whichever one you don't want to be the default. Select the "Extensions" tab, click the default box for extensions off, and add the desired extensions (without "h" or "H"). You can use Ctrl-C and Ctrl-V to copy the old extensions and paste them back after clicking the default box off.
If you set up the CSD generation environment (include path, predefined macros) exactly like the environment your compile command sees, and set the parse mode to "All Files", and if no structures are partly in a header file and partly in a source file (like an included function header), and if the code is ANSI C, CSD generation should work for your code. Setting all that up can be a pain, and parsing thousands of lines of headers can be slow, so this is usually not an option, unless you just want to generate a CSD once for printing or viewing.
If you can edit the code, the easiest thing to do is surround weird code with #ifndef _GRASP_IGNORE and #endif . _GRASP_IGNORE is set in the predefined macros for all compiler environments by default. For example:
#ifndef _GRASP_IGNORE
BEGIN_MESSAGE_MAP(CPrintApp, CWinApp)
ON_COMMAND(ID_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
#endif
This is an MFC message map. Without the ifndef, if all headers are parsed and the include path is set correctly, a CSD will be generated for this structure, but the indentation will not be what you expect, because the real structure is not what you expect.
For compiler extensions, setting predefined macros in the compiler environment can solve many problems. For example, you might define far to be nothing in an old 16 bit compiler.
For your own code, it is a good idea to use macros that look like real code. For example, you should leave a trailing semicolon out of a macro so it will be required in the code.