Filed under: Best Practices, Featured
  Comments: 1

This article provides a quick reference guide for learning Scheme and commonly used expressions. The target audience is for new NexJ developers who have previous programming experience.

Please refer to the Introduction to Scheme course for more in-depth discussion. Also, within NexJ Studio, you can mouse-over each function for details.

Primitives

Description Scheme example Java equivalent
Boolean true #t true
Boolean false #f false
Null () null
Integer 100 100
String “John” “John”
Timestamp
Binary #z1234567890ABCDEF new byte[] {18,52,86,120,-112,-85,-51,-17};
Character #\A ‘A’
Symbol symbol  

 

Declaration and Assignment

Description Scheme example Java equivalent
Global scope variable
Assign value to variable
Limited scope variable
Limited scope variable with reference to previously defined variable

Boolean logic

Description Scheme example Java equivalent
Not
And
Or
Null Check
Equal Check
Not Equal Check

 

Conditionals

Description Scheme example Java equivalent
If statement
If…else statement (single line body)
If…else statement (multi-line body)
Multi-condition if statement
Ternary Operator
Non-Boolean Condition

 

Collections

Description Scheme example Java equivalent
Collection
Collection Lookup by Index
Collection Length
Collection Empty Check
List
 
List Lookup by Index
List Length
 
List Empty Check
 
Collection/List Lookup by Value
 

 
Collection/List Filtering
 

 
Collection/List Sorting
 

 

 

Loops

Description Scheme example Java equivalent
For loop through collection/list
For loop using index

Functions

Description Scheme example Java equivalent
Declare function
Caution: Last expression is always the return value

 
Invoke function
 

 
Declare function with variable arguments
 

 
Invoke function with variable arguments
Function Documentation

Objects

Description Scheme example Java/SQL equivalent
Object instantiation
Object instantiation with arguments
Object Update
Object Delete
Object Association
Single Object Read
Caution: Throws error if more than 1 record exists
Multi Object Read

 

Logging

Description Scheme example Java equivalent
Info-level logging
Debug-level logging
Error-level logging

 

Error Handling

Description Scheme example Java equivalent
Raise error
Assertion error
Try..Catch..Finally
Try…Catch with restricted handler

 

Scheme Commands for Developers

Description Scheme example
Reset Scheme Console after metadata hotswap
 
Turn up SQL logging
Turn up RPC logging
Reseed Enumerations only

 

NexJ Studio Shortcuts

Description Shortcuts
Open file by name CTRL + SHIFT + D

This dialog includes files inherited from base models.

Open file by name CTRL + SHIFT + R

This dialog excludes files from base models.

File search by file content CTRL + H

Switch to “Model Search” tab

Execute selected text in Scheme Console CTRL + U
Select text between matching brackets CTRL + SHIFT + \
Auto code format CTRL + SHIFT + F
Code auto-complete CTRL + SPACE
Auto-indent as you type Window -> Preferences -> NexJ Studio -> Check “Auto-indent Scheme script as you type”
Delete current line CTRL + D
Block commenting CTRL + SHIFT + /
Rename variable ALT + SHIFT + R

 

Feedback

  Comments: 1


  1. Hi,
    Good read material for quick reference! Very helpful.
    Just a suggestion – can you also include “how to get & set a class attribute in current context” to the above list?

    Regards,
    Aditya Phatak.

Your feedback

You must be logged in to post a comment.