Create Component Library (#43)
* Move src under playlet-lib * Update configuration * Update script * Update script * Working version * Vs code config WIP * Package lock sync * Lint fix * Fix images * Reuse config files * Kind of a working setup * Lock node version * Rename scripts to tools * Fix build scripts, lib url system * Lint fix * rale * Fix args and web server * Load fallbacks and build script cleanups * Remove unused method * no message * no message * Remove generic message field * Lint fix * no message * Use loading indicator on main app * Add playlet lib version to settings --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
90df81df4b
commit
9d8a3d1cea
156 files changed
+3341
-213
No files matched your search
@@ -0,0 +1,149 @@
|
||||
REM Functions in this file:
|
||||
REM isnonemptystr
|
||||
REM isnullorempty
|
||||
REM strtobool
|
||||
REM itostr
|
||||
REM strTrim
|
||||
REM strTokenize
|
||||
REM
|
||||
|
||||
'******************************************************
|
||||
'isnonemptystr
|
||||
'
|
||||
'Determine if the given object supports the ifString interface
|
||||
'and returns a string of non zero length
|
||||
'******************************************************
|
||||
function isnonemptystr(obj as dynamic) as boolean
|
||||
return ((obj <> invalid) and (GetInterface(obj, "ifString") <> invalid) and (Len(obj) > 0))
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'isnullorempty
|
||||
'
|
||||
'Determine if the given object is invalid or supports
|
||||
'the ifString interface and returns a string of zero length
|
||||
'******************************************************
|
||||
function isnullorempty(obj as dynamic) as boolean
|
||||
return ((obj = invalid) or (GetInterface(obj, "ifString") = invalid) or (Len(obj) = 0))
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'strtobool
|
||||
'
|
||||
'Convert string to boolean safely. Don't crash
|
||||
'Looks for certain string values
|
||||
'******************************************************
|
||||
function strtobool(obj as dynamic) as boolean
|
||||
if obj = invalid
|
||||
return false
|
||||
end if
|
||||
if type(obj) <> "roString" and type(obj) <> "String"
|
||||
return false
|
||||
end if
|
||||
o = strTrim(obj)
|
||||
o = Lcase(o)
|
||||
if o = "true"
|
||||
return true
|
||||
end if
|
||||
if o = "t"
|
||||
return true
|
||||
end if
|
||||
if o = "y"
|
||||
return true
|
||||
end if
|
||||
if o = "1"
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
'******************************************************
|
||||
'booltostr
|
||||
'
|
||||
'Converts a boolean value to a cannonical string value
|
||||
'******************************************************
|
||||
function booltostr(bool as boolean) as string
|
||||
if bool = true
|
||||
return "true"
|
||||
end if
|
||||
return "false"
|
||||
end function
|
||||
|
||||
'******************************************************
|
||||
'itostr
|
||||
'
|
||||
'Convert int to string. This is necessary because
|
||||
'the builtin Stri(x) prepends whitespace
|
||||
'******************************************************
|
||||
function itostr(i as integer) as string
|
||||
str = Stri(i)
|
||||
return strTrim(str)
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Trim a string
|
||||
'******************************************************
|
||||
function strTrim(str as string) as string
|
||||
st = CreateObject("roString")
|
||||
st.SetString(str)
|
||||
return st.Trim()
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Tokenize a string. Return roList of strings
|
||||
'******************************************************
|
||||
function strTokenize(str as string, delim as string) as object
|
||||
st = CreateObject("roString")
|
||||
st.SetString(str)
|
||||
return st.Tokenize(delim)
|
||||
end function
|
||||
|
||||
function UnixNL() as string
|
||||
return chr(10)
|
||||
end function
|
||||
|
||||
function WinNL() as string
|
||||
return chr(13) + chr(10)
|
||||
end function
|
||||
|
||||
function Quote() as string
|
||||
return chr(34)
|
||||
end function
|
||||
|
||||
function StringLastIndexOf(str as string, substr as string) as integer
|
||||
index = str.InStr(substr)
|
||||
while index <> -1
|
||||
newIndex = str.InStr(index + 1, substr)
|
||||
if newIndex = -1
|
||||
return index
|
||||
end if
|
||||
index = newIndex
|
||||
end while
|
||||
return index
|
||||
end function
|
||||
|
||||
function PathJoin(path1 as string, path2 as string) as string
|
||||
if path1.EndsWith("/")
|
||||
path1 = path1.left(path1.len() - 1)
|
||||
end if
|
||||
if path2.StartsWith("/")
|
||||
path2 = path2.Mid(1)
|
||||
end if
|
||||
return path1 + "/" + path2
|
||||
end function
|
||||
|
||||
function ToBase64(input as string) as string
|
||||
buffer = createObject("roByteArray")
|
||||
buffer.FromAsciiString(input)
|
||||
return buffer.ToBase64String()
|
||||
end function
|
||||
|
||||
function FromBase64(input as string) as string
|
||||
buffer = createObject("roByteArray")
|
||||
buffer.FromBase64String(input)
|
||||
return buffer.ToAsciiString()
|
||||
end function
|
||||
Reference in new issue
Block a user