diff options
Diffstat (limited to 'testautomation/graphics/optional/includes/global/export_graphic_2.inc')
-rw-r--r-- | testautomation/graphics/optional/includes/global/export_graphic_2.inc | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/testautomation/graphics/optional/includes/global/export_graphic_2.inc b/testautomation/graphics/optional/includes/global/export_graphic_2.inc index 67c456201b45..5e0a2f3ec811 100644 --- a/testautomation/graphics/optional/includes/global/export_graphic_2.inc +++ b/testautomation/graphics/optional/includes/global/export_graphic_2.inc @@ -25,7 +25,7 @@ ' '/************************************************************************ '* -'* Owner : wolfram.garten@sun.com +'* Owner : wolfram.garten@oracle.com '* '* short description : Graphics Export B-tests. (the usual suspects) '* @@ -1430,3 +1430,91 @@ testcase tWMF endcase 'tWMF '------------------------------------------------------------------------- + +function fGetFileText (sFilename as string, iCount as long) as string +'/// This function is for getting the first or last n characters of a file +'///+<u>Input</u>:<ul><li>filename</li><li>number</li></ul>If the number greater 0 then get n characters from start. +'///+A number smaller 0 get from end of file. +'///+<u>Output</u>:<ul><li>string with <b><i>n</i></b> characters</li></ul> + + dim iFile as integer ' filehandle + dim iTem as integer ' get 2 bytes of the file + dim iTemByte(2) as integer ' move 1 byte from iTem in each item + dim sTemp as string ' string of file + dim iSize as long ' size in bytes of file + dim i as long ' runner :-) + + iFile = FreeFile +' Printlog "FreeFile: " + iFile + if (dir (sFilename) <> "") then +' Printlog "FileLen: " + FileLen(sFile) + Open sFilename For binary access read shared As #iFile +' Printlog "Loc: " + Loc(#iFile) ' LONG! where am i in the file? + + iSize = Lof(#iFile) ' get size in bytes of file + if (iSize > 65530) then '65536 = 64kB + 'Warnlog "fGetFileText: file '" + sFilename + "' might get problems on reading it? size is > 65530 Byte: '" + iSize + "'" + else +' printlog "iSize: " + iSize + endif + + sTemp = "" + if (iCount >= 0) then ' get bytes from file start + get iFile,1,sTemp ' get max 64kByte; but not the 1st 2 bytes :-( + get iFile,1,iTem ' get the first 2 bytes of the file + iTemByte(2) = (iTem AND &H0000FF00) \ &H100 ' and seperate the bytes + iTemByte(1) = (iTem AND &H000000FF) + sTemp = chr(iTemByte(1)) + chr(iTemByte(2)) + sTemp ' put them together + else ' get bytes from file end + if ((iSize+iCount) > 0) then + select case (iSize+iCount) + case 1: get iFile,1,sTemp ' take bytes from the end of the file + get iFile,1,iTem ' get the first 2 bytes of the file + sTemp = chr(iTemByte(2)) + sTemp ' put them together + case else: get iFile,(iSize+iCount)-1,sTemp ' take bytes from the end of the file + end select + else + get iFile,1,sTemp ' take bytes from the end of the file + get iFile,1,iTem ' get the first 2 bytes of the file + iTemByte(2) = (iTem AND &H0000FF00) \ &H100 ' and seperate the bytes + iTemByte(1) = (iTem AND &H000000FF) + sTemp = chr(iTemByte(1)) + chr(iTemByte(2)) + sTemp ' put them together + endif + endif +' printlog "'"+left(sTemp,iSize)+"'" ' gotcha! + + if (iSize-(Abs(iCount)) >= 0) then + fGetFileText = left(sTemp,Abs(iCount)) + else + 'Warnlog "fGetFileText: file '" + sFilename + "' isn't as big as expected; will only return '" + iSize+ "' bytes fom: " + iCount + fGetFileText = left(sTemp,iSize) + endif + + ' debugging routine -------------------------------------- + ' iSize = Lof(#iFile) + ' printlog "iSize: " + iSize + ' sTemp = "" + ' if iSize > 0 then + ' printlog "iSize \ 2: " + (iSize \ 2) + ' for i = 0 to ((iSize \ 2)-1) + ' get iFile,(i*2)+1,iTem + ' Printlog "i: " + i + ": 0x" + hex(iTem) + ' iTemByte(2) = (iTem AND &H0000FF00) \ &H100 + ' iTemByte(1) = (iTem AND &H000000FF) + ' sTemp = sTemp + chr(iTemByte(1)) + chr(iTemByte(2)) + ' next i + ' if (iSize MOD 2) = 1 then + ' get iFile,iSize,iTem + ' Printlog "i: " + iSize + ": 0x" + hex(iTem) + ' iTemByte(1) = (iTem AND &H000000FF) + ' sTemp = sTemp + chr(iTemByte(1)) + ' endif + ' endif + ' printlog "'"+sTemp+"'" + ' debugging routine -------------------------------------- + Close #iFile + else ' does file exist + Warnlog "fGetFileText: file '" + sFilename + "' doesn't exist" + fGetFileText = "" + endif +end function |