Knowledge Base

Welcome to The Carlisle Group's Knowledge Base.

Search or Ask a Question

This is a keyword search that looks for matching articles that contain one or more words specifically by a user in articles’ tags, title and content. Admin writes brief intro content here via admin end. If you are unable to find an answer to your issue, please submit an issue here.

Back to Articles List

Sample Script - Quick Guide to Looping | CAS

Added: 02/04/2013; Last Modified: 09/02/2015; Visits:1,919

CAS Scripting has basic "For" looping functionality.

 

The example below shows how to generate an index and run a basic "For" loop. 

⍝ Generate index to use in the loop.
 num←Numeric.New 3
 loopIndex←num.GenerateIndices 0

⍝ Start loop and show current index of loop.
 :For I :In loopIndex
     I.Show''
 :EndFor

 

It is possible to leave a loop early by using the ":Leave" statement.  Below is an example on breaking out of a loop if an "If" condition is met.

⍝ Generate index to use in the loop.
 num←Numeric.New 10
 loopIndex←num.GenerateIndices 0

⍝ Start loop and show current index of loop.
 :For I :In loopIndex
     I.Show''
     :If I.Eq 3
         :Leave
     :EndIf
 :EndFor