Jump to content
Sign in to follow this  
program builder

maybe simple may not even be possible

Recommended Posts

program builder

Lets say I have a notpad that has this written in it

1

note pad saying number one

2

notepad sayig number 2

is there anyway i can write a code that says something like

open("file.text")

find("1")

nextline = ("copy")

close("file.text")

filewrite("file.html/paste")

and get the words written in the text file to go into the new html document?

obvourse that wouldn't be the accaul code, but is there any way to do it?

Share this post


Link to post
Share on other sites
GEOSoft

$sStr = FileRead("C:\Some\File.txt")
$sHTML = "<html><head></head><body>" & @LF
$sHTML &= _Find("1") & @LF & "</body></html>"
$hFile = FileOpen("C:\Some\File.htm", 2)
FileWrite($hFile, $sHTML)
FileClose($hFile)

Func _Find($sWhatToFind)
$aFound = StringRegExp($sStr, "(?i)(?m:^)(.*" & $sWhatToFind & ".*)", 1)
If Not @Error Then Return $aFound[0]
Return ""
EndFunc


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
program builder

WhatToFind?

is there any way that i can tell it to just write the intire next line?

what I am trying to do is make it to where I don't have to add all the words to

the program. if i can just add numbers to the program, I can do it alot faster.

Share this post


Link to post
Share on other sites
maqleod

WhatToFind?

is there any way that i can tell it to just write the intire next line?

what I am trying to do is make it to where I don't have to add all the words to

the program. if i can just add numbers to the program, I can do it alot faster.

That is pretty much what he did, but alternatively, you can use FileReadLine()

or you can format it like an .ini and use IniRead()

Edited by maqleod

[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
GEOSoft

I used this text from your post to test with

;

open("file.text")

find("1")

nextline = ("copy")

close("file.text")

filewrite("file.html/paste")

;

The _Find function returned

find("1")

If it's the following line that you want then change

$aFound = StringRegExp($sStr, "(?i)(?m:^)(.*" & $sWhatToFind & ".*)", 1)

To

$aFound = StringRegExp($sStr, "(?i)(?m:^).*" & $sWhatToFind & ".*\v(.*)", 1)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
program builder

That worked; thank you for helping me out.

Edited by program builder

Share this post


Link to post
Share on other sites
GEOSoft

That worked; thank you for helping me out.

You're welcome

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
program builder

Sorry, but i found out it's not going to work. every time I try to put a new word into the html with this code, it copies over what was just written. I need it to put words in, every time I use it, not copy over each thing I say, and only have one word in the html file. Is there another code, that would work?

Edited by program builder

Share this post


Link to post
Share on other sites
maqleod

Sorry, but i found out it's not going to work. every time I try to put a new word into the html with this code, it copies over what was just written. I need it to put words in, every time I use it, not copy over each thing I say, and only have one word in the html file. Is there another code, that would work?

try using FileWriteLine() instead of FileWrite()


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
program builder

I tryed that and it didn't work.

Share this post


Link to post
Share on other sites
maqleod

I tryed that and it didn't work.

only other thing I can think to try is a bit messier, but it should work:

_FileCountLines and _FileWriteToLine - but not in overwrite mode, to find and write to the last line


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
program builder

only other thing I can think to try is a bit messier, but it should work:

_FileCountLines and _FileWriteToLine - but not in overwrite mode, to find and write to the last line

I don't want to do counttoline or filewritetoline because every time i tryed to add that same word again, it would probibly just copy over its own word, and not even put it as the next word.

Share this post


Link to post
Share on other sites
maqleod

I don't want to do counttoline or filewritetoline because every time i tryed to add that same word again, it would probibly just copy over its own word, and not even put it as the next word.

if you don't use _FileWriteToLine() in overwrite mode it will not overwrite.


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
GEOSoft

$sStr = FileRead("C:\Some\File.txt")
$sHTML = "<html><head></head><body>" & @LF
For $1 = 1 To 20;; Change this to suit your purposes
$sText = _Find("1");& @LF & "</body></html>"
If $sText Then
$sHTML &= $sText & @LF
Else
;; Put Some error code here (Like ExitLoop)
EndIf
Next
$hFile = FileOpen("C:\Some\File.htm", 2)
FileWrite($hFile, $sHTML & "</body></html>)
FileClose($hFile)

Func _Find($sWhatToFind)
$aFound = StringRegExp($sStr, "(?i)(?m:^)(.*" & $sWhatToFind & ".*)", 1)
If Not @Error Then Return $aFound[0]
Return ""
EndFunc


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
program builder

it is not working. What I am trying to do, is create a web-browser, where you can view pages that people create without any form of connection whatsoever. So what I am going to do is put every word in the english dictionary, as well as every persons first name and last name, numbered 1 through whatever

example

1

aardvark

2

ext

3

another name

and then people can create a website, and the numbers will be the address to get to it. I would like to also put about 50,000 sayings into it, so that it will shortan the address, and i would like to be able to turn the address into like 123.456.789. if you get the picture. thanks for helping. And if you know of a simpler way to do this please let me know. I am going to probably find a list of english words online, and then find a program out there that will number each one of them. like number one on line 1 number 2 on line three, ext, ext. if any of you would want to help me create this, I will start a chat about it, so please let me know.

Edited by program builder

Share this post


Link to post
Share on other sites
maqleod

it is not working. What I am trying to do, is create a web-browser, where you can view pages that people create without any form of connection whatsoever. So what I am going to do is put every word in the english dictionary, as well as every persons first name and last name, numbered 1 through whatever

example

1

aardvark

2

ext

3

another name

and then people can create a website, and the numbers will be the address to get to it. I would like to also put about 50,000 sayings into it, so that it will shortan the address, and i would like to be able to turn the address into like 123.456.789. if you get the picture. thanks for helping. And if you know of a simpler way to do this please let me know. I am going to probably find a list of english words online, and then find a program out there that will number each one of them. like number one on line 1 number 2 on line three, ext, ext. if any of you would want to help me create this, I will start a chat about it, so please let me know.

honestly, I would look into using a database, look at the SQLite UDFs, you might find it easier to do this sort of thing that way


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
GEOSoft

Do you have any idea how many words are in the english language?

This site only contains the words form 2 to 16 letters and you can see how long those files are.

http://www.theargon.com/achilles/wordlists/. Also you would be better off to number the begining of each line instead of inserting a line above it (thereby doubling the number of lines). DataBase or separate array's based on the first letter would be the way to go.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
GEOSoft

Here is a short example of what I mean by the line numbering.

1 aardvark

2 aardwolf

3 aaron

4 aback

5 abacus

6 abaft

7 abalone

8 abandon

9 abandoned

10 abandonment

11 abandons

12 abase

13 abased

14 abasement

15 abash

16 abashed

Working from that (my full list is over 58000 words), the regexp becomes simple. by the way, I created the list by first writing a list to an array and adding the number + space to the array elements. so it would be possible to just call the array elements by number as well.

Edit: The list is British spelling only with hyphens removed. If you also want American spellings then they would have to be added.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×