Touch Technologies, Inc.
Coding Standards


Previous Contents Index

5.8 GOLD/F to Fixup Right Margin

To wrap long lines of code, the GOLD/F keystroke can be used in SPDEV. In a .SPSRC file, SPDEV will automatically wrap the code at the correct place, insert a & or + at the right margin, and correctly indent the code on the next line.

To set the column number for the right margin wrapping, click on Options in the SPDEV toolbar, then select Change System Settings.

The Settings dialog box will appear. Here the Word Wrap feature can be enabled or disabled, and the right margin column number can be configured.

The following example shows how SheerPower wraps code at the right margin (SheerPower automatically wraps the code as it is being written if Word Wrap is enabled):

Example 5-9 GOLD/F to Wrap Long Lines of Code

! The following is a long line of code to be wrapped:
 
  line input menu '"calculator" = Calculator,"DOS Prompt" = DOS Prompt, "EXIT MENU"': choice$ 
 
! Place your cursor on the line of code anywhere, then press GOLD/F. If
! there is more than 1 line to wrap, highlight the code to be wrapped, 
! then press GOLD/F. The line of code will now look like:
 
  line input menu '"calculator" = Calculator,"DOS Prompt" = DOS Prompt, ' + 
   '"EXIT MENU"': choice$ 

5.9 GOLD / (Forward Slash) to Comment or Uncomment

To comment out or uncomment lines or blocks of code/text, you can use the GOLD / keystroke. To use this keystroke, just highlight the text/code you want to comment/uncomment, then press the GOLD / keystroke. SPDEV will automatically insert two forward slashes at the start of each line, or it will remove them.

The compiler ignores lines that begin with the double forward slash, as well as exclamation marks.

The following example illustrates how the GOLD / keystroke works:

Example 5-10 GOLD / Keystroke to Comment

! Copy/paste the sample code into an .spsrc file in SPDEV, then 
! highlight the code using your mouse.
 
  dim months$(6) 
  data January, February, March 
  data April, May, June 
  for i = 1 to 6 
    read months$(i) 
    print months$(i) 
  next i 
  end 
  
! Now press either GOLD key (Escape or Num-Lock), let go, then
! press the forward slash key (/). The code will then look like:
 
//  dim months$(6) 
//  data January, February, March 
//  data April, May, June 
//  for i = 1 to 6 
//    read months$(i) 
//    print months$(i) 
//  next i 
//  end 

To UNCOMMENT a line or block of text/code, just highlight the text and press the GOLD / (forward slash) keystroke. SheerPower will automatically remove the "//" (double forward slash) from the beginning of each line.

This feature allows you to easily have two sets of code within a routine (TEST and PRODUCTION) where you can alternate using one or the other by commenting and uncommenting them out at the same time. For example:

Example 5-11 Comment and Uncomment Code Simultaneously

! Note: the first section of code is already commented out. 
! To switch back and forth between the two sections of code, 
! highlight all of the code and press GOLD /.
 
//  a$ = "one"  
//  b$ = "two" 
//  c$ = "three" 
//  print a$; ', '; b$; ', '; c$ 
  
  a$ = "testing one..."   !++ debug sw October 12, 2003 
  b$ = "testing two..."   !++ debug sw October 12, 2003 
  c$ = "testing three..." !++ debug sw October 12, 2003 
  print a$                !++ debug sw October 12, 2003 
  print b$                !++ debug sw October 12, 2003 
  print c$                !++ debug sw October 12, 2003 
  
! After pressing GOLD /, the code will then look like:
 
  a$ = "one" 
  b$ = "two" 
  c$ = "three" 
  print a$; ', '; b$; ', '; c$ 
//  
//  a$ = "testing one..."   !++ debug sw October 12, 2003 
//  b$ = "testing two..."   !++ debug sw October 12, 2003 
//  c$ = "testing three..." !++ debug sw October 12, 2003 
//  print a$                !++ debug sw October 12, 2003 
//  print b$                !++ debug sw October 12, 2003 
//  print c$                !++ debug sw October 12, 2003 
 
! And the first section of code can be run with the second
! section ignored by the compiler.

5.10 GOLD/DOWN and UP Arrow to Change Case

You can change the CASE of the text/code inside any file open in SheerPower by using the GOLD/DOWN ARROW or GOLD/UP ARROW keystrokes.

SheerPower ignores any quoted text.

This makes it simple to convert written code to lower case while keeping quoted text case intact.

Example 5-12 GOLD/DOWN and UP Arrow for Changing Case

! To convert the code below to be ALL lower case, first
! highlight the code:
 
  A$ = "ONE" 
  B$ = "TWO" 
  C$ = "THREE" 
  PRINT A$; ', '; B$; ', '; C$; 
  
! Now press the GOLD key, let go, then press the DOWN
! Arrow key. All code not inside of quotes will become
! lower case automatically:
 
  a$ = "ONE" 
  b$ = "TWO" 
  c$ = "THREE" 
  print a$; ', '; b$; ', '; c$; 
  
! GOLD/UP Arrow works the same way, changing all unquoted 
! text/code into upper case.

5.11 Tab Key to Indent

To make indentation easier, you can use the TAB key in SPDEV. Just highlight the line or block of text/code that you want indented, then press the Tab key. The highlighted selection will indent 2 spaces. To further indent, simply continue to press the Tab key until the desired indentation is reached.

The following example shows how the Tab key can be used for indenting code.

Example 5-13 TAB Key for Indentation

! The code below is incorrectly all left-aligned. Highlight the 
! 3 lines making up the body of the routine using your mouse.
 
routine print_data 
print '--1-- --2--' 
print using "##.## ##.##": 1.3, 1.25 
end 
end routine 
 
! Then press the TAB key. The routine body will automatically indent 
! 2 spaces in:
 
routine print_data 
  print '--1-- --2--' 
  print using "##.## ##.##": 1.3, 1.25 
  end 
end routine 

5.12 Shift + Tab to Reverse Indent

You can reverse indent any text or code by first highlighting the line or block of text/code, then pressing the Shift + Tab keys. The highlighted selection will reverse indent 2 spaces.

The following example will show how using the Shift + Tab key can easily correct "over-indentation."

Example 5-14 Shift + Tab Key to Reverse Indent

! The following code has the body of the routine indented 
! too far under the routine name. Highlight the 3 lines that 
! make up the body of the routine using your mouse.
 
routine print_integer 
    z = integer(4 + (993 * 35)) 
    print z 
    end 
end routine 
 
! Now press the Shift key, hold it down, then press the Tab key.
! The highlighted code will move back 2 spaces to be indented 
! correctly.
 
routine print_integer 
  z = integer(4 + (993 * 35)) 
  print z 
  end 
end routine 

5.13 Keystrokes for Professional Software Development Summary

Using specially mapped keystrokes in SPDEV can greatly improve the quality of code organization, structure, documentation and efficiency. Since the keystrokes can be used as the program is being written, less time is spent trying to fix up the code at the end. This produces code that is clean, easy to read and simple to understand.

For a complete listing of mapped keystrokes in SPDEV, see Appendix F in the SheerPower 4GL, A Guide to the SheerPower Language documentation.

The keymap in SPDEV can be customized to suit any individual preference. See Appendix H in the SheerPower 4GL, A Guide to the SheerPower Language documentation.


Previous Next Contents Index