winkot Posted September 22 Share Posted September 22 I'm trying to open a file via WinAPI #include <WinAPI.au3> $File = _WinAPI_CreateFile(@ScriptDir & '\Test.txt', 2) $Text=FileRead($File) ConsoleWrite($Text & @CRLF) _WinAPI_CloseHandle($File) Exit But it still won't read. What's wrong? Link to comment Share on other sites More sharing options...
Developers Jos Posted September 22 Developers Share Posted September 22 Use fileopen() instead of the winapi. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
winkot Posted September 22 Author Share Posted September 22 (edited) FileOpen() does not allow opening a file for both reading and writing. And that is exactly what I need. Edited September 22 by winkot Link to comment Share on other sites More sharing options...
donnyh13 Posted September 22 Share Posted September 22 It does, just not at once. But you use set position.... Check out Example 2 of the help file. https://www.autoitscript.com/autoit3/docs/functions/FileOpen.htm Also LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions." Link to comment Share on other sites More sharing options...
winkot Posted September 23 Author Share Posted September 23 I need to read certain lines in a file. And I don't know at what positions the lines start and end. How can I use it in this case FileSetPos? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23 Moderators Share Posted September 23 wincot, Use FileReadToArray to get the content of the file into a variable and you can then manipulate the array as you wish. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
winkot Posted September 23 Author Share Posted September 23 (edited) Yes. I also come to the conclusion that it is better to work through arrays. It seems that it is not very convenient to work with Win API functions. Isn't it? Edited September 23 by winkot donnyh13 1 Link to comment Share on other sites More sharing options...
donnyh13 Posted September 23 Share Posted September 23 (edited) Winkot, Melba23's suggestion is definitely easier when reading and writing to specific lines. FileOpen can do it, but it gets complex, and can be error prone when reading and writing to multiple lines. My apologies. Have a good day. Edited September 23 by donnyh13 LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions." Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now