Sign in to follow this  
Followers 0
GoravG

How to read next text without already read text

3 posts in this topic

I am confuse, how to read next text without already read text...

 

My Script...

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.0
 Author:         GoravG



#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>

$GUI = GUICreate("String To Hex",1550,600)
$HE = GUICtrlCreateEdit("",1,1,1550,570, $WS_VSCROLL)
$Input = GUICtrlCreateInput("",900,575,300,20,4096)
$B = GUICtrlCreateButton("Open File", 300,575,200,20)
$B1 = GUICtrlCreateButton("Save File", 600,575,200,20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $B
            $FO = FileOpenDialog("","","(*.*)")
            GUICtrlSetData($Input,$FO)
            If GUICtrlRead($Input) Then
            $R = FileRead(GUICtrlRead($Input),2000)
            ProcessWaitClose($R)
            $R1 = FileRead(GUICtrlRead($Input),-2000) ; error, how to read next text without already read text
            ProcessWaitClose($R1)
            GUISetState(@SW_DISABLE, $GUI)
            GUICtrlSetData($HE,"$Hex ="&' '&'"'&_StringToHex($R)&'" & _'&' '&'"'&_StringToHex($R1)&'" & _'&' ')
            GUISetState(@SW_ENABLE, $GUI)
            FileChangeDir(@ScriptDir)
            Else
            EndIf

        Case $B1
            $FS = FileSaveDialog("","","(*.*)")
            FileWrite($FS,GUICtrlRead($HE))
            FileChangeDir(@ScriptDir)

    EndSwitch
WEnd

I am new, i am not programmer.....

Sorry my bad English......

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look in the helpfile for FileGetPos and FileSetPos

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

    Local Const $sFilePath = @TempDir & "\FileGetPos.txt"
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If @error Then Exit
    FileWriteLine($hFileOpen, "Line 1")
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "Line 3")
    FileFlush($hFileOpen)

    FileSetPos($hFileOpen, 0, $FILE_BEGIN)
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    FileSetPos($hFileOpen, 0, $FILE_BEGIN)
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen, 8))

    FileSetPos($hFileOpen, 8, $FILE_BEGIN)
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    FileSetPos($hFileOpen, 16, $FILE_BEGIN)
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    FileClose($hFileOpen)
    FileDelete($sFilePath)

or (easier) use the integrated String* funcs to cut the string returned by FileRead in parts and then read them successively

Edited by mikell

Share this post


Link to post
Share on other sites

mikell

thanks to reply


I am new, i am not programmer.....

Sorry my bad English......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0