Sign in to follow this  
Followers 0
protfromkpax

insert text on the first line

25 posts in this topic

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:-)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
MVP: thank you very much, I'm sure I will use it well!
 
for John: fast and accurate. That's what I was looking for (the few I was looking for :-) )
 
Do not ask if it is possible to delete a line with a specific text and delete empty line.
thank you

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

i´m absolutly beginner, I wrote only a few small things,

Now I'm trying to finish a script on lines 500 and something you really can not help it.
and I still think that this is my last problem :-D

Share this post


Link to post
Share on other sites
Retrieves the file path (  C:dir1file.txt  ) using the command "FileOpenDialog"
Retrieves the path to another directory (  C:dir2  ) using the command "FileSelectFolder"
 
You need a fold path to the file         file.txt + C:Dir2   =   C:dir2file.txt

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Alalujah!

#include <StringConstants.au3>
 
$text = FileOpenDialog("", "", "(*.*)")
    Local $aArray = StringSplit($Text, '', $STR_ENTIRESPLIT)
 
        $number = $aArray[0]
 
$file = $aArray[$number]
MsgBox(0, "", $file)
 
 
Problem solved?

Share this post


Link to post
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.

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