diff options
Diffstat (limited to 'testautomation/global/system/includes/inivalue.inc')
-rwxr-xr-x[-rw-r--r--] | testautomation/global/system/includes/inivalue.inc | 361 |
1 files changed, 159 insertions, 202 deletions
diff --git a/testautomation/global/system/includes/inivalue.inc b/testautomation/global/system/includes/inivalue.inc index e73aa240fef5..cf70fa365f7e 100644..100755 --- a/testautomation/global/system/includes/inivalue.inc +++ b/testautomation/global/system/includes/inivalue.inc @@ -37,243 +37,200 @@ ' #1 SetIniValue2 ' subroutine for SetIniValue ' #1 ChangeExt ' change the extension of an file ' #1 AnhaengenAnDatei ' add a string into a file -' #1 DateiSperren ' set the hidden flag for file -' #1 DateiFreigeben ' reset the hidden flag for file '* '\**************************************************************** function GetIniValue ( Datei$, Gruppe$, Variable$ ) as String -'/// wrapper for GetIniValue2 ///' -'///+ reads a value from an ini-file ///' -'///+ INPUT : name of ini-file; name of group (the one in braces []); the item (left of '=') ///' -'///+ OUTPUT: value (the right of the '=') ///' - if Dir(Datei$) = "" then - Warnlog "Error in GetIniValue(...):" + Datei$ + " not found" - exit function - end if - - GetIniValue = GetIniValue2( Datei$, Gruppe$, Variable$ ) ' Arbeiten + '/// wrapper for GetIniValue2 ///' + '///+ reads a value from an ini-file ///' + '///+ INPUT : name of ini-file; name of group (the one in braces []); the item (left of '=') ///' + '///+ OUTPUT: value (the right of the '=') ///' + if Dir(Datei$) = "" then + Warnlog "Error in GetIniValue(...):" + Datei$ + " not found" + exit function + end if + + GetIniValue = GetIniValue2( Datei$, Gruppe$, Variable$ ) ' Arbeiten end function function SetIniValue( Datei$, Gruppe$, Variable$, Value$ ) as String -'/// wrapper for SetIniValue2 ///' -'///+ writes a value to an ini-file ///' -'///+ INPUT : name of ini-file; name of group (the one in braces []); the item (left of '='); value (the right of the '=') ///' -'///+ OUTPUT: - ///' - Dim FileNum as Integer - - if Dir(Datei$) = "" then - WarnLog "Error in SetIniValue(...):" + Datei$ + " not found. File will be created now!" - FileNum = FreeFile - Open Datei$ For Output As #FileNum ' make empty file - Print #FileNum, "" - Close #FileNum - end if - - SetIniValue = SetIniValue2( Datei$, Gruppe$, Variable$, Value$ ) + '/// wrapper for SetIniValue2 ///' + '///+ writes a value to an ini-file ///' + '///+ INPUT : name of ini-file; name of group (the one in braces []); the item (left of '='); value (the right of the '=') ///' + '///+ OUTPUT: - ///' + Dim FileNum as Integer + + if Dir(Datei$) = "" then + WarnLog "Error in SetIniValue(...):" + Datei$ + " not found. File will be created now!" + FileNum = FreeFile + Open Datei$ For Output As #FileNum ' make empty file + Print #FileNum, "" + Close #FileNum + end if + + SetIniValue = SetIniValue2( Datei$, Gruppe$, Variable$, Value$ ) end function function GetIniValue2( Datei$, Gruppe$, Variable$ ) as String -'/// see the wrapper for it : GetIniValue ///' - Dim FileNum% : Dim GruppeOK% : Dim Pos% : Dim IniZeile$ : Dim IniZeile2$ - - FileNum% = FreeFile - - GruppeOK%=FALSE - - GetIniValue2 = "" - - Open Datei$ For Input As #FileNum% - do until EOF(#FileNum%) = True - Line input #FileNum%, IniZeile$ - - IniZeile$ = TRIM(IniZeile$) - iniZeile2$ = UCASE( IniZeile$ ) ' compare case insensitive - if GruppeOK% = FALSE then ' still no group - if IniZeile2$= "[" + UCASE( Gruppe$ ) + "]" then 'Is it the wanted group? - GruppeOK% = TRUE - end if - else - If Left(IniZeile2$, 1) = "[" then 'sadly new group - goodby - Exit do - else - Pos% = Instr( IniZeile2$, "=" ) 'is the item valid? - if Pos%>0 then ' '=' not found - if Left( IniZeile2$ , Pos%-1 ) = UCASE( Variable$ ) then 'compare leftvalue - GetIniValue2 = Trim(Mid$( IniZeile$ , Pos%+ 1 )) 'return part right of '=' : with initial case - exit do - end if - end if - end if - end if - - loop - - Close #FileNum% - wait 1000 -end function - - -sub SetIniValue2( Datei$, Gruppe$, Variable$, Value$ ) as String -'/// see the wrapper for it : SetIniValue ///' - Dim DateiBak$ : Dim D$ : Dim IniZeile$ : Dim IniZeile2$ - Dim FileBak% : Dim GruppeOK% : Dim Gefunden% : Dim FileNum% : Dim Pos% + '/// see the wrapper for it : GetIniValue ///' + Dim FileNum% : Dim GruppeOK% : Dim Pos% : Dim IniZeile$ : Dim IniZeile2$ -' rename - DateiBak$ = ChangeExt( Datei$, "BAK" ) + FileNum% = FreeFile - GruppeOK% = FALSE - Gefunden% = FALSE + GruppeOK%=FALSE - if Dir(DateiBak$)<>"" then - kill DateiBak$ - end if + GetIniValue2 = "" - if Dir( Datei$ )<>"" then - D$ = CurDir - name Datei$ as DateiBak$ - else - FileNum% = FreeFile - Open Datei$ For Output As #FileNum% - Print #FileNum%, "[" + Trim(Gruppe$) + "]" - Print #FileNum%, Variable$ + "=" + Trim(Value$) - Close #FileNum% ' finished here - Exit sub - endif + Open Datei$ For Input As #FileNum% + do until EOF(#FileNum%) = True + Line input #FileNum%, IniZeile$ - FileNum% = FreeFile - Open Datei$ For Output As #FileNum% - - FileBak% = FreeFile - Open DateiBak$ For Input As #FileBak% - - do until EOF(#FileBak%) = True - - Line input #FileBak%, IniZeile$ + IniZeile$ = TRIM(IniZeile$) + iniZeile2$ = UCASE( IniZeile$ ) ' compare case insensitive + if GruppeOK% = FALSE then ' still no group + if IniZeile2$= "[" + UCASE( Gruppe$ ) + "]" then 'Is it the wanted group? + GruppeOK% = TRUE + end if + else + If Left(IniZeile2$, 1) = "[" then 'sadly new group - goodby + Exit do + else + Pos% = Instr( IniZeile2$, "=" ) 'is the item valid? + if Pos%>0 then ' '=' not found + if Left( IniZeile2$ , Pos%-1 ) = UCASE( Variable$ ) then 'compare leftvalue + GetIniValue2 = Trim(Mid$( IniZeile$ , Pos%+ 1 )) 'return part right of '=' : with initial case + exit do + end if + end if + end if + end if - IniZeile$ = TRIM(IniZeile$) + loop - if IniZeile$ <> "" then + Close #FileNum% + wait 1000 +end function - IniZeile2$ = UCASE( IniZeile$ ) - if Left(IniZeile$, 1) = "[" then - if GruppeOK% = TRUE then 'groupchange - if Gefunden%=FALSE then - Print #FileNum%, Variable$ + "=" + Trim(Value$) - Gefunden% = TRUE - end if - GruppeOK% = FALSE - end if - Print #FileNum%, "" 'empty line - Print #FileNum%, IniZeile$ - if IniZeile2$= "[" + UCASE( Gruppe$ ) + "]" then - GruppeOK% = TRUE - end if - else - if GruppeOK% = TRUE then ' found group - - Pos% = Instr( IniZeile$, "=" ) - if Left( IniZeile2$ , Pos%-1 ) = UCASE( Variable$ ) then - IniZeile$ = Left( IniZeile$ , Pos% ) +Trim( Value$ )' after the '=' - Gefunden% = TRUE - end if +sub SetIniValue2( Datei$, Gruppe$, Variable$, Value$ ) as String + '/// see the wrapper for it : SetIniValue ///' + Dim DateiBak$ : Dim D$ : Dim IniZeile$ : Dim IniZeile2$ + Dim FileBak% : Dim GruppeOK% : Dim Gefunden% : Dim FileNum% : Dim Pos% + + ' rename + DateiBak$ = ChangeExt( Datei$, "BAK" ) + + GruppeOK% = FALSE + Gefunden% = FALSE + + if Dir(DateiBak$)<>"" then + kill DateiBak$ + end if + + if Dir( Datei$ )<>"" then + D$ = CurDir + name Datei$ as DateiBak$ + else + FileNum% = FreeFile + Open Datei$ For Output As #FileNum% + Print #FileNum%, "[" + Trim(Gruppe$) + "]" + Print #FileNum%, Variable$ + "=" + Trim(Value$) + Close #FileNum% ' finished here + Exit sub + endif + + FileNum% = FreeFile + Open Datei$ For Output As #FileNum% + + FileBak% = FreeFile + Open DateiBak$ For Input As #FileBak% + + do until EOF(#FileBak%) = True + + Line input #FileBak%, IniZeile$ + + IniZeile$ = TRIM(IniZeile$) + + if IniZeile$ <> "" then + + IniZeile2$ = UCASE( IniZeile$ ) + + if Left(IniZeile$, 1) = "[" then + if GruppeOK% = TRUE then 'groupchange + if Gefunden%=FALSE then + Print #FileNum%, Variable$ + "=" + Trim(Value$) + Gefunden% = TRUE + end if + GruppeOK% = FALSE + end if + Print #FileNum%, "" 'empty line + Print #FileNum%, IniZeile$ + if IniZeile2$= "[" + UCASE( Gruppe$ ) + "]" then + GruppeOK% = TRUE + end if + else + if GruppeOK% = TRUE then ' found group + + Pos% = Instr( IniZeile$, "=" ) + if Left( IniZeile2$ , Pos%-1 ) = UCASE( Variable$ ) then + IniZeile$ = Left( IniZeile$ , Pos% ) +Trim( Value$ )' after the '=' + Gefunden% = TRUE + end if + end if + Print #FileNum%, IniZeile$ end if - Print #FileNum%, IniZeile$ - end if - end if + end if - loop + loop - if Gefunden% = FALSE then - ' set new group and value - if GruppeOK%=FALSE then - Print #FileNum%, "" - Print #FileNum%, "[" + Trim(Gruppe$) + "]" - end if - Print #FileNum%, Variable$ + "=" + Value$ - end if + if Gefunden% = FALSE then + ' set new group and value + if GruppeOK%=FALSE then + Print #FileNum%, "" + Print #FileNum%, "[" + Trim(Gruppe$) + "]" + end if + Print #FileNum%, Variable$ + "=" + Value$ + end if - Close #FileNum% - Close #FileBak% + Close #FileNum% + Close #FileBak% - wait 1000 + wait 1000 end sub sub AnhaengenAnDatei ( Datei as String, Texte as String ) -'/// append a string at the end of the file ///' -'///+ INPUT : filename; string///' -'///+ OUTPUT: - ///' - Dim FileNum% + '/// append a string at the end of the file ///' + '///+ INPUT : filename; string///' + '///+ OUTPUT: - ///' + Dim FileNum% - FileNum% = FreeFile - Open Datei for Append as #FileNum% + FileNum% = FreeFile + Open Datei for Append as #FileNum% - Print #FileNum%, Texte - Close #FileNum% + Print #FileNum%, Texte + Close #FileNum% end sub function ChangeExt( Datei$, Ext$ )as String -'/// change the extension of a file ///' -'///+ INPUT : filename; extension ///' -'///+ OUTPUT: - ///' - Dim i% - - i% = InStr( Right(Datei$, 4 ) , "." ) - if Ext$<>"" then - if i%=0 then - ChangeExt = Datei$ +"."+Ext$ - else - ChangeExt = Left( Datei$, Len(Datei$)-4+i% ) + Ext$ - end if - - elseif i%<>0 then - ChangeExt = Left( Datei$, Len(Datei$)-5+i% ) - end if + '/// change the extension of a file ///' + '///+ INPUT : filename; extension ///' + '///+ OUTPUT: - ///' + Dim i% + + i% = InStr( Right(Datei$, 4 ) , "." ) + if Ext$<>"" then + if i%=0 then + ChangeExt = Datei$ +"."+Ext$ + else + ChangeExt = Left( Datei$, Len(Datei$)-4+i% ) + Ext$ + end if + + elseif i%<>0 then + ChangeExt = Left( Datei$, Len(Datei$)-5+i% ) + end if end function -sub DateiSperren( Datei$ ) -'/// set the hidden flag of a file; lock the file ///' -'///+ INPUT : filename ///' -'///+ OUTPUT: - ///' - Dim i% - - if hFileExists ( Datei$ ) <> TRUE then - Warnlog "File '" + Datei$ + "' doesn't exist; exiting now!" - exit sub - end if - - i% = GetAttr( Datei$ ) - do while (i% AND 2) = 2 ' is file already locked? - Wait( int( 400 * Rnd + 5 ) - i% = GetAttr( Datei$ ) - loop - SetAttr( Datei$ , i% OR 2 ) ' Lock - - exit sub - -end sub - -sub DateiFreigeben( Datei$ ) -'/// reset the hidden flag of a file; release the file ///' -'///+ INPUT : filename ///' -'///+ OUTPUT: - ///' - Dim i% - - if hFileExists ( Datei$ ) <> TRUE then - Warnlog "File '" + Datei$ + "' doesn't exist; exiting now!" - exit sub - end if - - i% = GetAttr( Datei$ ) - SetAttr( Datei$ , i% AND NOT 2 ) ' release - exit sub - -end Sub - - - |