Read-only Mode in VS Code for IBM i
If you are using the Code for i extension and would like to “browse” or view certain source members without the risk of modifying them, use the “Read only” or “Protected” capability.
Possible reasons to enable “Protected” or read-only mode may include:
- It is a production or QA environment
- You only want to do research on code, not change it
- Providing an environment to someone who is learning
Protected mode can be enabled at a connection level or the filter level. Either way, the setting must be done on each individual Code for i installation that you want protected.
Connection level
To protect your source code for an entire connection, as with a production environment, here are the steps:
- Right-click on your IBM i connection name and choose “Connection Settings”
- Select the “Source Code” tab
- Check the box for “Read only mode”
- Click “Save settings”
The “Source Code” tab with “Read only mode” is shown below.
Now, you will see a “Lock” icon next to the connection name, as shown below.
Filter level
To protect your source code for only a specific filter (a source code type, name etc.), here are the steps:
- From the Object Browser, right-click the filter you want to protect and choose “Maintain Filter”
- Select the “Source Code” tab
- Check the “Protected” checkbox
- Click Save settings
Screen shots of the steps are shown below.
Now, you will see a “Lock” icon next to your filter name, as shown below.
VS Code for i Resource Guide
For additional tips and documentation on Visual Studio Code for i, check out our resource guide.
I have all those options deactivated but VSCode keeps opening sources just for read-only, why could it be?
Javier, check the the Code for IBM i output tab for the CHKOBJ command when the member is opened.
Without creating a new connection or new filter, is there a way to toggle an open source member to read-only? Rdi does this and I used this feature all the time. If VS Code can’t, this would be a great feature to add.
You can use the commands “Open File…” (Alt-Ctrl-O) and “Open File (readonly)…” (Alt-Ctrl-P), which will open a dialog, where you can enter the member path. The readonly command will open the member – well, as readonly…
You can’t change the mode of an opened file from “modifying” to “readonly” and vice versa. You have to close the member and open it again in the desired mode.
Re-opening a member is easy now, since we have implemented “Recent files” in the dialogs – so the most recently used file will be shown in the top of the list in the open file dialog. You can configure how many recent files you want in the list – press Ctrl-, and select the Code for IBM i extension. The config value is called “Recently Opened Files Limit” and the default value is 10.
We have also implemented search function in the commands, so you can type the beginning of the library / file / member and ‘*’ and the server will show the matching libraries / files / members.
HTH.
Best regards,
Christian
Sorry, my previous post were incorrect – the commands are called “Go To file” and the hotkeys are
Ctrl-Alt-P => Go To file… ( for update)
Ctrl-Alt-O => Go To file (Read Only)…
Best regards,
Christian
Thanks, Christian!