Jump to content

Reading from a file, then writing every line with a for/next loop


Swift
 Share

Recommended Posts

I have created a script to read from a dll file using _FileReadToArray and then use that array in a For/Next loop to GUICtrlSetData() and set the data for EACH line but its only sending 1 0... :) heres my code below:

Just create a dummy dll with some like 5 lines of random stuff, and save it as a .dll called: SkyNet.dll, to the script dir and run this code and press y once it shows up.

#include <GUIConstants.au3>
#include <File.au3>
#include <Misc.au3>
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Skynet System Core", 499, 231, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 497, 233, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "Skynet System Core Engage? [Y/N]?")
Global $Engage = 1
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
    If $Engage = 1 Then
        If _IsPressed(59) Then
            Global $Engage = 0
            _Display()
        EndIf
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _Display()
    Dim $Array
    $Sky = FileOpen("Skynet.dll", 0)
    _FileReadToArray($Sky, $Array)
    For $Array = 0 To $Array Step 1
    GUICtrlSetData($Edit1, $Array)
Next
EndFunc
Link to comment
Share on other sites

Func _Display()
    Dim $temp
    Dim $Array
    $Sky = FileOpen("Skynet.dll", 0)
    $Array = StringSplit(FileRead($sky),@lf)
    For $I = 1 To $Array[0] Step 1
        $temp = $temp & $Array[$i] & @lf
    Next
    GUICtrlSetData($Edit1, $temp)
EndFunc

That should do it.

Edit: Just saw your nvm

Edited by mmavipc

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Link to comment
Share on other sites

Incase anyone wanted to see what I did..here...

#include <GUIConstants.au3>
#include <File.au3>
#include <Misc.au3>
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Skynet System Core", 499, 231, -1, -1)
Global $Edit1 = GUICtrlCreateEdit("", 0, 0, 497, 233, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetData(-1, "Skynet System Core Engage? [Y/N]?")
Global $Engage = 1
Global $Load = 0
Global $LoadTime=25
Global $ExeTime=15
GUISetState()
Send("{END}")
#EndRegion ### END Koda GUI section ###

While 1
    If $Engage = 1 Then
        If _IsPressed(59) Then
            Global $Engage = 0
            _Display()
        EndIf
    EndIf
    If $Load = 1 Then
        If _IsPressed(59) Then
            _Execute()
            Global $Load = 0
        EndIf
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _Display()
    Dim $Array
    $SkyFile = @ScriptDir & "\SkyNet.dll"
    _FileReadToArray($SkyFile, $Array)
    GUICtrlSetData($Edit1, "")
For $x = 1 to $Array[0]
    Sleep($LoadTime)
    GUICtrlSetData($Edit1, $Array[$x] & @CRLF & GUICtrlRead($Edit1))
Next
GUICtrlSetData($Edit1, "Execute? [Y/N]?" & @CRLF & GUICtrlRead($Edit1))
Global $Load = 1
EndFunc

Func _Execute()
    Dim $Array
    $SkyFile = @ScriptDir & "\SkyNet.dll"
    _FileReadToArray($SkyFile, $Array)
    GUICtrlSetData($Edit1, "Executing Skynet System Core...Please Wait...")
    Sleep(5000)
    For $x = 1 to $Array[0]
    Sleep($ExeTime)
    GUICtrlSetData($Edit1, "Executing: " & $Array[$x] & @CRLF & GUICtrlRead($Edit1))
Next
Global $Load = 0
GUICtrlSetData($Edit1, "Reconizing System Core...Please Wait..." & @CRLF & GUICtrlRead($Edit1))
Sleep(2000)
GUICtrlSetData($Edit1, "Connecting To Skynet System Core...Please Wait..." & @CRLF & GUICtrlRead($Edit1))
Sleep(2000)
GUICtrlSetData($Edit1, "Connected To Skynet System Core" & @CRLF & GUICtrlRead($Edit1))
Sleep(1000)
GUICtrlSetData($Edit1, "Skynet System Core Now Online..." & @CRLF & GUICtrlRead($Edit1))
EndFunc

This above requires a Skynet.dll file..that you can make and just put random stuff in :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...