-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathConvertToCamelCase.ahk
54 lines (38 loc) · 1.01 KB
/
ConvertToCamelCase.ahk
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
ConvertToCamelCase(ByRef fnCopiedText)
{
; converts text to camelCase
; MsgBox fnCopiedText: %fnCopiedText%
; declare local, global, static variables
Try
{
; set default return value
ReturnValue := 0 ; success
; validate parameters
If !fnCopiedText
Throw, Exception("fnCopiedText was empty")
; initialise variables
; convert to Pascal case
ConvertToPascalCase(fnCopiedText)
; decapitalise the first character
PCRE := "iS)^(\w)(.*)"
NewString := RegExReplace(fnCopiedText,PCRE,"$L1$2")
; set the value of the ByRef parameter
fnCopiedText := NewString
}
Catch, ThrownValue
{
ReturnValue := !ReturnValue
CatchHandler(A_ThisFunc,ThrownValue.Message,ThrownValue.What,ThrownValue.Extra,ThrownValue.File,ThrownValue.Line,0,0,0)
}
Finally
{
}
; return
Return ReturnValue
}
/* ; testing
#Include ahkfn_ConvertToPascalCase.ahk
params := "hello there matey"
ReturnValue := ConvertToCamelCase(params)
MsgBox, ConvertToCamelCase`n`nReturnValue: %ReturnValue%`n`nparams: %params%
*/