-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
cache-basic.scroll
90 lines (77 loc) · 2.52 KB
/
cache-basic.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import ../code/conceptPage.scroll
id cache-basic
name Caché Basic
appeared 1997
tags queryLanguage
conceptDescription Caché is a high-performance object database with several built-in general-purpose programming languages. It supports multiple processes and provides concurrency control. Each process has direct, efficient access to the data.
centralPackageRepositoryCount 0
country United States
originCommunity InterSystems Corporation
reference https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=TBAS_ARoutine
example
' RightTriangle compute area and hypotenuse of a right triangle
' this routine contains examples of Cache Basic features */
Sub Run()
println "Compute the area and hypotenuse of a right triangle"
println "given the lengths of its two sides."
println
println "First, choose a unit of measurement. "
input "(i)nches, (f)eet, (m)iles, " _
, "(c)entimeters, m(e)ters, (k)ilometers: ", units
println
' translate units to a full word
select case left(units, 1)
case "i" units = "inches"
case "f" units = "feet"
case "m" units = "miles"
case "c" units = "centimeters"
case "e" units = "meters"
case "k" units = "kilometers"
case else units = "units"
end select
do
println
input "Length of side 1: ", side1
if (side1) = "" then exit do
loop while IsNegative( side1 )
if (side1 = "") then exit sub
do
println
input "Length of side 2: ", side2
if (side2) = "" then exit do
loop while IsNegative( side2 )
if (side2 = "") then exit sub
Compute(units, side1, side2)
end sub
public function IsNegative(ByVal num As %String) As %Boolean
' is num negative?
' check in range "1" through "9"
if (num < chr(49)) or (num > chr(57)) then
print " Enter a positive number."
return True
else
print " Accepted."
return False
end if
end function
private function Compute(ByVal units As %String, _
ByVal A As %Integer, _
ByVal B As %Integer)
' compute and display area and hypotenuse
area = round((( A * B ) / 2), 2)
hypot = round(sqr(( A ^ 2 ) + ( B ^ 2 )), 2)
println : println
println "The area of this triangle is ", area, " square ", units, "."
println
println "The hypotenuse is ", hypot, " ", units, "."
end function
lineCommentToken '
printToken println
booleanTokens True False
hasLineComments true
' A comment
hasComments true
' A comment
hasPrintDebugging true
hasSemanticIndentation false
hasBooleans true