summaryrefslogtreecommitdiff
path: root/testautomation/global/tools/includes/required/t_dir.inc
diff options
context:
space:
mode:
authorJoerg Skottke [jsk] <jsk@openoffice.org>2010-09-09 13:11:38 +0200
committerJoerg Skottke [jsk] <jsk@openoffice.org>2010-09-09 13:11:38 +0200
commitd93f1af562e459899b1c2e41405069d0240644d4 (patch)
treed0bd852fedb3f8f2bf713549fa2898dd8f3f68cf /testautomation/global/tools/includes/required/t_dir.inc
parent04873f78c8cd0594d1beaabe50f8cb38135eb665 (diff)
automationdev300m87: #i112208# - Implemented fuction to work with a local copy of a file which resides anywhere else in the filesystem. The file is then copied to the users work directory and opened from there. This is experimental and the function needs to be called explicitly. The function is another workaround for the paramount problem that we cannot reliably switch a readonly document to edit-mode. Used the opportunity to introduce a new global variable (and fix the case of others, as they are not constants as they were initially planned to be)
Diffstat (limited to 'testautomation/global/tools/includes/required/t_dir.inc')
-rw-r--r--[-rwxr-xr-x]testautomation/global/tools/includes/required/t_dir.inc40
1 files changed, 40 insertions, 0 deletions
diff --git a/testautomation/global/tools/includes/required/t_dir.inc b/testautomation/global/tools/includes/required/t_dir.inc
index ee673e6b1c47..a7347d4d498d 100755..100644
--- a/testautomation/global/tools/includes/required/t_dir.inc
+++ b/testautomation/global/tools/includes/required/t_dir.inc
@@ -288,4 +288,44 @@ function GetExtention ( Datei as String ) as string
next i%
GetExtention = Datei
end function
+'
+'-------------------------------------------------------------------------------
+'
+function hSplitString( sString as string, sSeparator as string, iIndex as integer ) as string
+
+ ' This function wraps around the "split" command and returns one single
+ ' item by index. Index = 0 means the *LAST* item is returned as this is
+ ' probably the most commonly used item. If the index is invalid (out of
+ ' bounds) we print a warning and return an error string.
+
+ const CFN & "global::tools::includes::required::t_dir.inc:hSplitString(): "
+ const ERROR_MESSAGE = "Array out of bounds for the requested index in string "
+ const ARRAY_INDEX_CORRECTION = 1 ' The array lower boundary is zero but
+ ' function starts to count with one.
+
+ ' Split the string into its fragments into an array with dynamic boundaries
+ dim sArray() as string: sArray() = split( sString, sSeparator )
+ dim sReturnString as string
+
+ ' Special case: Index out of bounds
+ if ( iIndex > ( ubound( sArray ) + ARRAY_INDEX_CORRECTION ) or iIndex < 0 ) then
+ warnlog( CFN & ERROR_MESSAGE & sString )
+ hSplitString() = ERROR_MESSAGE & sString
+ exit function
+ endif
+
+ ' Special case: Last item requested (this usually is the filename from a path)
+ if ( iIndex = 0 ) then
+ sReturnString = sArray( ubound( sArray() )
+ if ( GVERBOSE ) then printlog( CFN & sReturnString )
+ hSplitString() = sReturnString
+ exit function
+ endif
+
+ ' Default is to return the requested item.
+ sReturnString = sArray( iIndex - ARRAY_INDEX_CORRECTION )
+ if ( GVERBOSE ) then printlog( CFN & sReturnString )
+ hSplitString() = sReturnString
+
+end function