how to load q script in q studio?

Hi, 

I had a problem when trying to load a q script in qStudio.  

The q script “sp.q” is under the q home folder, so I could load it successfully in a prompt window by simply typing in: \l sp.q

However, the code didn’t work in qStudio. An error message came out saying “Error: sp.q: No such file or directory”  

How could I load it in qStudio?   Also, if the script isn’t under the q home folder,  how could I load it in a q prompt window? 

Any help and suggestions are sincerely appreciated! 

Best,

Xinyu

Hi,

You should check what directory you are in using the \pwd command. It is possible qstudio has placed you outside the q home directory.

To load the file you can specify the complete path to the file.

For example if you are using windows you can enter \l C:\q\sp.q to load the file.

Regards,

Thomas Smyth

AquaQ Analytics

Hi Thomas, 

Thanks a lot for your kind reply. 

How could I set directory in qStudio to q home? 

I typed in \pwd and it returned : [0] = “/kdb/data/hdb”.   I think I am connected to a hdb port at this moment, but I don’t know how to disconnect it and set qStudio working directory to a local directory. Could you please give me some further instructions? Thanks!

Best

Xinyu   

Hi,

Where is your sp.q file located? Normally the QHOME directory is on the file path so running \l sp.q should find and load the file.

In this case it sounds like the file is not defined under the QHOME directory which gives you two options:

  1. Create a copy of the file under QHOME.
  2. Specify the full path to the file in order to load it. E.g. \l <full path>/sp.q.

Additionally, if the sp.q does not exist you may have to download it and place it on the server. It can be found at: http://kx.com/q/sp.q

Regards,

Thomas

Hi Thomas,

I double checked that my sp.q file is located at C:\q. 

I could load it in q prompt console just by typing in “\l sp.q” , however I don’t know why this didn’t work in qStudio. 

This really make me confused now. I even tried with  “\l C:\q\sp.q” which also didn’t work. 

Is it possible for me to reset the default working directory of qStudio?  Thanks a lot!

Best

Xinyu

Hi,

I also delete all the server connections on qStudio, and when I ran “\cd” , an error message showed up saying “There are no connections defined. Please add a server connection”

Is this error related with the above problem? 

Thanks

Xinyu 

Problem solved, I guess I didn’t really understand how does the system work.

       1.  run cmd.exe in start menu and type in “q -p 5000”, set up a local server on port 5000

       2.  open rStudio and add a connection to the local sever

       3.  \l sp.q should work totally fine. 

Thanks again for all the suggestions and help!  

Best 

Xinyu

Hi Xinyu,

This video demonstrates all the steps required: https://youtu.be/P7aYu_nxWzs

system \l are only needed to load server files.

Mostly you can use control+E to load code from your local machine to any kdb process.

Regards,

Ryan


www.timestored.com
Tel: +44 (0) 20 3397 7535
Email: ryan@timestored.com