Jump to content

insert text on the first line


Recommended Posts

Friends help me.
description of the problem:
There is a file that is structured like windows ini file, but lacks the early indications [section]. When would I managed to write the FIRST LINE of the expression "[section]" I treat him like a classic * .ini file (need it !!!).
What you need:
function that writes the selected text to the first line in the file (please, no solution 'run ("notepad.exe ... Send (" [section] "..) CloseFile () ...), but something like the" FileWriteLine "or "IniWrite".
Then you need to find the file in a text string and the delete and find and delete empty lines.
For help, thank you, and I apologize for English (it's not me, but google translator:-)
Link to comment
Share on other sites

Welcome to AutoIt and the forum!

I would start with_FileReadToArray to read the whole file into an array.

Then use IniWrite and IniWriteSection to create the ini file from the needed lines.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

BTW: MVP is not the name of my account - it's "water". MVP stands for "Most valuable participant" (or something similar) ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

for Water: ...i´m sorry, i´m sorry, i´m sorry... :-)

Nothing to be sorry about :)

I'm sure you will never do it again :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I need you help again.

I have the link to file (  $file = FileOpenDialog("...", "@UserProfileDir", " (*.txt)")  ), the link is in the format: C:Userpcfile.txt.

Input format for external SW is in the format C:Userpcfile.txt.

Could you help me?

 

Something like this?

 

$filename = "c:\x\y\z"
ConsoleWrite("Before: " & $filename & @CRLF)
$filename = StringReplace($filename, "\", "\\")
ConsoleWrite("After: " & $filename  & @CRLF)
... which outputs:

 

Before: c:\x\y\z
After: c:\\x\\y\\z

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

I need you help again.

I need to create a file link to the selected folder:

Before:       input file       $FileSelectFolder( ... )   =>   C:xyz
                   input folder     FileOpenDialog( ... )   =>   D:ab
 
After:       C:abZ
 
I do not need to copy the file, but only to create a destination link.
thank you
Link to comment
Share on other sites

;bad code

O.ops, sorry.

Local $sFileSelectFolder = FileSelectFolder("Select a folder", "")
Local $FileOpenDialog = FileOpenDialog("Select a file", @HomeDrive, "(*.*)")
MsgBox(0, 0, $sFileSelectFolder & StringTrimLeft($FileOpenDialog, 2))
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

 

Problem solved if you combine the codes from  #16 and #17

Local $sFileSelectFolder = FileSelectFolder("Select a folder", "")
Local $FileOpenDialog = FileOpenDialog("Select a file", @HomeDrive, "(*.*)")
Local $tmp = StringSplit($FileOpenDialog, '\')

MsgBox(0, 0, $sFileSelectFolder & "\" & $tmp[$tmp[0]])

That produces the exact same result as the code I posted.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...