Jump to content

A program that reads database.txt which contains 3 elements seperated by a comma each


handro
 Share

Recommended Posts

Database.txt:

1,Noun,Image.jpg

For now, i'm trying to create a program that reads database.txt, reads each line of the file, takes element one "1", and creates a directory using it like this:

C:\Image.X , since line 1, element 1, is "1" , it would be, C:\Image.1

I can think of how this would work but i cant program it..help very appriciated

Edited by handro
Link to comment
Share on other sites

$line=0
Do
    $Line+=1
    $LineRead=FileReadLine("Database.txt",$Line)
    If $LineRead="" Then ExitLoop
    $Split=StringSplit($LineRead,",")
    $DirN=StringSplit($Split[3],".")
    DirCreate("C:\"&$DirN[1]&"."&$Split[1])
Until $LineRead=""

Link to comment
Share on other sites

Thanks a lot,

This worked exactly like I needed it to. I'm sorry to ask you to directly write the code for this, but I am having a hard time concentrating on what I need to learn first, I'm in a stressful position right now, If you can please help me finish this I will promise that I am going to learn from this.

continuing with the program,

I have made the program copy a folder "arnov" to Jpeg.1-Jpeg.4

These folders Jpeg.1-4 contain a file "filename.html"

I wrote "RPLRPLRPLRPLR" on

Line 49:

Column 40-53

i want to learn how to replace that string with element 2 in Database.txt

help is very appreciated I will learn how to use autoit i'm very time pressured listing excuses is shit im trying to learn though

Link to comment
Share on other sites

Thanks a lot,

This worked exactly like I needed it to. I'm sorry to ask you to directly write the code for this, but I am having a hard time concentrating on what I need to learn first, I'm in a stressful position right now, If you can please help me finish this I will promise that I am going to learn from this.

continuing with the program,

I have made the program copy a folder "arnov" to Jpeg.1-Jpeg.4

These folders Jpeg.1-4 contain a file "filename.html"

I wrote "RPLRPLRPLRPLR" on

Line 49:

Column 40-53

i want to learn how to replace that string with element 2 in Database.txt

help is very appreciated I will learn how to use autoit i'm very time pressured listing excuses is shit im trying to learn though

While you can read a selected line out of a file, I don't know a way to write to a specific line number. So you will have to read the entire file, modify it, then write it all back. If the search string is unique, or you want to replace every instance of it, then you can read the entire file into a single string with FileRead(), replace the value with StringReplace(), and then write the whole string back with FileOpen()/FileWrite()/FileClose().

If you need to find that particular line, then it will be easier to read the file to an array with _FileReadToArray(), do the StringReplace() on $avArray[49], then write the whole thing back with _FileWriteFromArray().

Play with the examples in the help file for those commands.

In case of errors, always write back to a different file name than you read from. Makes disaster recovery and "Oops" moments easier to deal with...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't know a way to write to a specific line number.

Hi,

Of course you do, but you don't want to have to think about it...

Don't forget my ;TailRW.au3, link in signature, does just that; but only useful if you need speed in gigantic files, the line is near start or end, and prepared to "pad" the line, or curtail it if you need superspeed; etc etc;

Otherwise fileReadToArray, FileWriteToArray, etc etc is correct!

best, randall

Link to comment
Share on other sites

Hi,

Of course you do, but you don't want to have to think about it...

Don't forget my ;TailRW.au3, link in signature, does just that; but only useful if you need speed in gigantic files, the line is near start or end, and prepared to "pad" the line, or curtail it if you need superspeed; etc etc;

Otherwise fileReadToArray, FileWriteToArray, etc etc is correct!

best, randall

Well, OK:

"I don't know a way to write to a specific line number... using a single included AutoIt function."

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...