Read-only Mode in VS Code for IBM i

Code for IBM iIf 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.

Source code tab of Code for i connection settings with read-only selected

Source code tab of Code for i connection settings with read-only selected

Now, you will see a “Lock” icon next to the connection name, as shown below.

Read-only connection lock

Read-only connection lock

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.

Maintain filter

Maintain filter

 

Protected Option on Source Code Tab

Protected Option on Source Code Tab

Now, you will see a “Lock” icon next to your filter name, as shown below.

Protected filter with Lock

Protected filter with Lock

 

VS Code for i Resource Guide

For additional tips and documentation on Visual Studio Code for i, check out our resource guide.

 

4 replies
  1. Glenn Gundermann
    Glenn Gundermann says:

    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.

    Reply
    • Christian Jorgensen
      Christian Jorgensen says:

      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

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.