How to install q in another directory? - kdb

I am trying to install q in a directory other than my home directory. Is this possible? It seems q will fail if it is in another directory. I get this error when trying to run it:
'/Users/cammil/q/q.k. OS reports: No such file or directory
0::
`/Users/cammil/q/q.k

Set your QHOME to directory which contains q.k file. That should solve the issue.
Also, if that directory does not contain k4.lic (license) file then set QLIC to directory containing license file.
Read more details about environment variables here: https://code.kx.com/q4m3/14_Introduction_to_Kdb+/#1481-the-environment-variables

KDB+ uses the QHOME environment variable at startup. QHOME specifies where to find the q.k file, and if it is not defined kdb will by default look into the home directory. It will also look for the licence file in the same way. Therefore you must define your QHOME variable as the directory which holds the .q.k and k4.lic files. (Or alternativley you can define the QLIC variable for the license)

Related

Loading files in Matlab

In my code I want to indicate paths to files that are independent on which computer the code is run. In other words, I want the script to operate only in the folder where it is located because my friend's computer can have different drive names, folders' names etc. The task is to load files by indicating where they are located. I thought this would work: "load("..\Folder\file.mat")". However, Matlab gives an error
Error using load
'..\Folder\file.mat' is not found in the current folder or on the MATLAB path, but exists in:
D:\D (synced)\Folder 3\Matlab
D:\D (synced)\Folder 3\Data
Change the MATLAB current folder or add its folder to the MATLAB path.
I checked and file.mat is in Folder which is located in the same directory as the script that I run.
Could someone tell how to make all paths independent on what computer they are run and avoid the error?
I suppose that both your script and file are in the folder Folder.
To make it operating system independent, you could use mfilename to retrieve the path of your script, and use fullfile to concatenate the path with the file name.
p = mfilename( 'fullpath');
file = load( fullfile( p, 'file.mat'));

vscode: Where stores the session data (restored opened files)? Is that possible to use relative path?

If I use vscode to open a directory and then opened some files and quit, vscode will reopen all the files at the next time when it launches.
But there is a problem. It seems vscode is not using relative path for storing this info and does not store this info inside the project directory. So if I move the directory or rename it, and then open the directory again, for example code projectNewName/, my previous session (opened files/opened editors) are lost. I have no idea where this session data stores and if it is possible to configure it to store relative path and save the session file inside the project directory, for example, project/.vscode or project/.vscode/session. If the opened editors session is stored inside a project directory, it will be restored regardless where the directory is and what the directory name is.
TL;DR: currently, configuration of this path is not supported.
VSCode stores the states for all the workspaces, in its global config folder under /Code/User/workspaceStorage/. See the path to the settings.json in this help paragraph for your OS and then just replace the end of the path. For Windows, for example, the settings path is %APPDATA%\Code\User\settings.json, so the state storage is
%APPDATA%/Code/User/workspaceStorage/
In this directory, there are many subdirectories with some hex names. Please, refer to my another answer for a python script to browse it. Each folder contains a workspace.json with mostly data only referring to the path of the workspace. There are also state.vscdb files in these directories. These are sqlite databases with only one table:
CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB);
It is used as a key|value storage for all the state variables like:
workbench.panel.output|{"workbench.panel.output":{"collapsed":false,"isHidden":true}}
As far as I see from VSCode source, currently only a global path from the environment is used to locate this file:
this.environmentService.workspaceStorageHome
this.environmentService.globalStorageHome
which resolves to
get workspaceStorageHome(): URI { return URI.joinPath(this.appSettingsHome, 'workspaceStorage'); }
get globalStorageHome(): URI { return URI.joinPath(this.appSettingsHome, 'globalStorage'); }
So, it seems there are currently no options to customize it from the settings.json.

MATLAB path doesn't match pathdef

I am running MATLAB 2013b on a CentOS machine. Right now I have startup.m set to cd me into another directory, lets call it shared, where I keep all of my code. I also have pathdef.m set to add shared and some of its subdirectories to the MATLAB path.
The problem is that once MATLAB is open and I check the path settings, ~/matlab has also been added to the top of the path list, ahead of shared. The home folder is where I keep some old versions of code, so it causes the wrong version to be run sometimes. I've double checked my pathdef and startup files, and the ~/matlab directory is definitely not listed. What could be causing MATLAB to automatically add this directory to the path, and how can I fix it?

Is there a way to determine the directory the file being executed resides in?

And if so, is there way that asdf can import a symbol that is calculated in runtime.
I'm trying to to specify the directory on which the project resides so the test runner can find the input files and also when I run from the repl.
Yes, system-relative-pathname and system-source-directory are your friends. At least if you execute from source.
It depends on what you mean by "execution".
If your code is executed when your file is loaded, take a look at Variable *LOAD-PATHNAME*, *LOAD-TRUENAME*.
If you need the current working directory, asdf has getcwd and chdir.

Specifying relative paths in SPSS 18

In SPSS 11 it was possible to specify relative paths. Example:
FILE HANDLE myfile='..\..\data\current.txt' /LRECL=533.
DATA LIST FILE=myfile /
...
This worked because apparently, SPSS 11 set the working folder to the path where the source .SPS file is saved. It seems that SPSS 18 always sets it's working folder to the installation folder of SPSS itself. Which is not at all the same thing.
Is there an option to change this behaviour? Or am I stuck with changing everything to absolute filenames?
Instead of a relative path, you could define a directory path and use it inside other file handle declarations to save typing:
FILE HANDLE directoryPath /NAME='C:\Directory\Path\' .
FILE HANDLE myFile /NAME='directoryPath/fileName.xyz' .
GET FILE='myFile' .
This will get the file: C:\Directory\Path\fileName.xyz.
The direction of the slashes may be important.
(Works in version 17)
If you use the INSERT command to run an sps file, it has an option to change the working directory to that location.
You could use the HOST command to SUBST a drive letter (on PCs) and reference everything through that.
You could define a FILE HANDLE to the common root location and use that in file references.
You could use Python programmability to find the path to the active syntax window and issue an SPSS CD command to set the backend working directory appropriately.
HTH,
Jon Peck
With Python, you can get the full path of the current syntax window (or any other one) and get its path. Using that you can issue an SPSS cd command to change the backend working directory accordingly.
If you define an environment variable, though, you can use that in file specifications within SPSS.
p.s. SPSS has an extensive set of apis and helper modules for Python (as well as for R and .NET languages). You can get information about this from SPSS Developer Central, www.spss.com/devcentral. All the language extensions are free once you have the base SPSS Statistics product.
Regards,
Jon Peck
Or use "CD" command to change your default working directory. See also:
http://www.spss-tutorials.com/change-your-working-directory/
For example, if your default directory is C:\project, then GET FILE 'data\data_file.sav'. will open data_file.sav from C:\project\data.
And then, a few minutes later, i came across this little python script from jignesh-sutar (see here: SPSS syntax - use path of the file.
With his python code you can use the path of the syntax file as starting point for all the paths in your syntax.