Skip to content

Commit 44fe481

Browse files
committed
from Word formatting to lower
1 parent 6218d2f commit 44fe481

File tree

9 files changed

+641
-645
lines changed

9 files changed

+641
-645
lines changed

.vscode/settings.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"ns": "SAMPLES",
77
},
88
"objectscript.format": {
9-
"commandCase": "word",
10-
"functionCase": "word"
9+
"commandCase": "lower",
10+
"functionCase": "lower"
1111
},
1212
"objectscript.export": {
1313
"folder": "src",
14+
"addCategory": false
1415
}
1516
}

src/ObjectScript/DataEntry1.cls

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ Class ObjectScript.DataEntry1
33

44
ClassMethod Main()
55
{
6-
Read !, "Name: " , name
7-
If name = "" { quit } // user entered nothing
8-
Read !, "Phone: ", phone
9-
Read !, "DOB: ", dob
6+
read !, "Name: " , name
7+
if name = "" { quit } // user entered nothing
8+
read !, "Phone: ", phone
9+
read !, "DOB: ", dob
1010

1111
// display the data
12-
Write !!!, "Name:", ?20, name
13-
Write !, "Phone:", ?20, phone
14-
Write !, "DOB:", ?20, dob
12+
write !!!, "Name:", ?20, name
13+
write !, "Phone:", ?20, phone
14+
write !, "DOB:", ?20, dob
1515
}
1616

1717
}

src/ObjectScript/DataEntry2.cls

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ Class ObjectScript.DataEntry2
44
/// Main loop section
55
ClassMethod Main()
66
{
7-
While ..Prompt() {
8-
Do ..Display()
7+
while ..Prompt() {
8+
do ..Display()
99
}
1010
}
1111

1212
/// prompt
1313
ClassMethod Prompt() As %Boolean [ PublicList = (name, phone, dob) ]
1414
{
15-
Read !, "Name: ", name
16-
Return:(name = "") 0 // user entered nothing so return FALSE and exit method
17-
Read !, "Phone: ", phone
18-
Read !, "DOB: ", dob
19-
Return 1 // return true
15+
read !, "Name: ", name
16+
return:(name = "") 0 // user entered nothing so return FALSE and exit method
17+
read !, "Phone: ", phone
18+
read !, "DOB: ", dob
19+
return 1 // return true
2020
}
2121

2222
/// display the data
2323
ClassMethod Display() [ PublicList = (name, phone, dob) ]
2424
{
25-
Write !!, "========================================"
26-
Write !, "Name:", ?20, name
27-
Write !, "Phone:", ?20, phone
28-
Write !, "DOB:", ?20, dob
29-
Write !, "========================================", !
25+
write !!, "========================================"
26+
write !, "Name:", ?20, name
27+
write !, "Phone:", ?20, phone
28+
write !, "DOB:", ?20, dob
29+
write !, "========================================", !
3030
}
3131

3232
}

src/ObjectScript/DataEntry3.cls

+47-49
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,90 @@ Class ObjectScript.DataEntry3
44
/// Main loop section
55
ClassMethod Main()
66
{
7-
While ..Prompt(.answers) {
8-
Do ..Display(answers)
7+
while ..Prompt(.answers) {
8+
do ..Display(answers)
99
}
1010
}
1111

1212
/// prompt
1313
ClassMethod Prompt(ByRef answers As %String) As %Boolean
1414
{
15-
Do {
16-
Read !, "Name: ", name
17-
Return:(name = "") 0 // user entered nothing so return FALSE, exit loop AND method
18-
}
19-
While '..ValidName(name)
15+
do {
16+
read !, "Name: ", name
17+
return:(name = "") 0 // user entered nothing so return FALSE, exit loop AND method
18+
} while '..ValidName(name)
2019

21-
Do {
22-
Read !, "Phone (617): ", phone
23-
}
24-
While '..ValidPhone(.phone)
20+
do {
21+
read !, "Phone (617): ", phone
22+
} while '..ValidPhone(.phone)
2523

26-
Do {
27-
Read !, "DOB: ", dob
28-
}
29-
While '..ValidDOB(dob, .intdob)
30-
Set answers = $Listbuild(name, phone, intdob)
31-
Return 1 // return true
24+
do {
25+
read !, "DOB: ", dob
26+
} while '..ValidDOB(dob, .intdob)
27+
set answers = $listbuild(name, phone, intdob)
28+
return 1 // return true
3229
}
3330

3431
/// use pattern match to validate a name in "Last,First" format.
3532
/// write error message if invalid
3633
ClassMethod ValidName(name As %String) As %Boolean
3734
{
38-
If (name?1U.L1","1U.L) {
39-
Return 1 }
40-
Else {
41-
Write !,"Last,First"
42-
Return 0
43-
}
35+
if (name?1U.L1","1U.L) {
36+
return 1
37+
}
38+
else {
39+
write !,"Last,First"
40+
return 0
41+
}
4442
}
4543

46-
/// use RegEx ($Match) to validate a phone in "###-####" or "###-###-####" format.
44+
/// use RegEx ($match) to validate a phone in "###-####" or "###-###-####" format.
4745
/// returns the converted phone by reference
4846
/// write error message if invalid
4947
ClassMethod ValidPhone(ByRef phone As %String) As %Boolean
5048
{
51-
If $Match(phone, "(\d{3}-)?\d{3}-\d{4}") {
52-
Set:($Match(phone, "\d{3}-\d{4}")) phone = "617-" _ phone // add default area code
53-
Return 1
49+
if $match(phone, "(\d{3}-)?\d{3}-\d{4}") {
50+
set:($match(phone, "\d{3}-\d{4}")) phone = "617-" _ phone // add default area code
51+
return 1
5452
}
55-
Else {
56-
Write !, "###-###-#### or ###-####"
57-
Return 0
53+
else {
54+
write !, "###-###-#### or ###-####"
55+
return 0
5856
}
5957
}
6058

61-
/// validate a date of birth using $ZDateh and $Horolog
59+
/// validate a date of birth using $zdateh and $horolog
6260
/// returns the internal form of the date of birth by reference
6361
/// write error message if invalid
6462
ClassMethod ValidDOB(date As %String, Output convdate As %Date) As %Boolean
6563
{
66-
Set convdate = $ZDateh(date, 5,,,,,,, -1)
67-
If (convdate = -1) {
68-
Write !,"Must be a valid past date"
69-
Return 0 // invalid date
64+
set convdate = $zdateh(date, 5,,,,,,, -1)
65+
if (convdate = -1) {
66+
write !,"Must be a valid past date"
67+
return 0 // invalid date
7068
}
71-
ElseIf (convdate > $Piece($Horolog, ",", 1)) {
72-
Write !,"Must be a valid past date"
73-
Return 0 // invalid because it's in the future
69+
elseif (convdate > $piece($horolog, ",", 1)) {
70+
write !,"Must be a valid past date"
71+
return 0 // invalid because it's in the future
7472
}
75-
Else {
76-
Return 1 // valid date
73+
else {
74+
return 1 // valid date
7775
}
7876
}
7977

8078
/// display the data
8179
ClassMethod Display(answers As %String)
8280
{
83-
Set $Listbuild(name, phone, intdob) = answers
81+
set $listbuild(name, phone, intdob) = answers
8482
/* the line above is equivalent to
85-
Set name = $List(answers, 1),
86-
phone = $List(answers, 2),
87-
intdob = $List(answers, 3) */
88-
Write !!, "========================================"
89-
Write !, "Name:", ?20, name
90-
Write !, "Phone:", ?20, phone
91-
Write !, "DOB:", ?20, $ZDate(intdob, 2)
92-
Write !, "========================================", !
83+
set name = $list(answers, 1),
84+
phone = $list(answers, 2),
85+
intdob = $list(answers, 3) */
86+
write !!, "========================================"
87+
write !, "Name:", ?20, name
88+
write !, "Phone:", ?20, phone
89+
write !, "DOB:", ?20, $zdate(intdob, 2)
90+
write !, "========================================", !
9391
}
9492

9593
}

0 commit comments

Comments
 (0)