33 lines
796 B
AutoHotkey
33 lines
796 B
AutoHotkey
integer_of_length(num, num_len) {
|
|
num := RegExReplace(num, "[^\d+]")
|
|
return RegExMatch(num, "^\d{" . num_len . "}$")
|
|
}
|
|
|
|
;; Checks valid 10 digit number supplied (doesnt do checksums)
|
|
valid_nhs_number(patient_nhs) {
|
|
result := integer_of_length(patient_nhs, 10)
|
|
return result
|
|
}
|
|
|
|
test_valid_nhs_number() {
|
|
test1 := valid_nhs_number(1234567890) ;; pass
|
|
test2 := valid_nhs_number("123 456 7890") ;; pass
|
|
test3 := valid_nhs_number("123456789") ;; fail
|
|
|
|
if (test1 and test2 and not test3 ) {
|
|
MsgBox,,"Test","Test Passed: valid_nhs_number"
|
|
} else {
|
|
MsgBox,,"Test","Test Failed: valid_nhs_number"
|
|
}
|
|
}
|
|
|
|
; Returns bool based on presence of 'match' string in window title
|
|
check_in_win_title(match) {
|
|
WinGetTitle, Title, A
|
|
If InStr(Title, match)
|
|
{
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
} |