Hi
bama
Thank You igimax for trying to help.
. No problem! I will be happy to help others, If I can!
The insertion should be at
first line of the text file then I should have an empty line, or (the
other option: after the first paragraph (after the first paragraph there
is the second paragraph but I don't have an empty line in between)
. The new option need less coding! But I found I was mistaken about one of the RT commands! So! now you can do both options with RT.. Todo both above options you still need those three loops, But the "Insertion Point" place inside second loop and base on which option you choose, writing the codes for each one will be different! (of course!) . The code will do this in simple steps:1) found "Article Files" at first folder by *.txt condition.2) Read lines of founded "Article File"3) Write each lines at new file at another location with the same filename of "Article File"4) When it's reach to "Insertion Point", the sentence line will write at new file.5) After writing all lines go to step 1 to found another "Article File". Your loops should look like this simple codes:(Read/Bold worlds are RT Commands and variable are GREEN/Bold): //---------------------------------------------------------- ------01> File Loop (return "full path & file name" of all files at "Article Folder" that have "*.txt" condition, one by one and store it at a variable. let's call it "ARTICLE_FILENAME")02>>... COUNT_FOUNDED_ARTICLE_FILES += 1 (Add one to this variable, we will use this counter to know which line of "second text files" should be insert to the current "Article file")03>>... NEW_ARTICLE_FILENAME (store new path + same article filename at this variable)04>> Text Loop (read line by line of "ARTICLE_FILENAME" file and store each line at "READ_ARTICLE_LINE")05>>>...Check If "Insertion Point" reach codes?? (base on your choose insertion point will be place here, and if it reach, variable "INSERTION_STATUS" will be True)06>>>... If {INSERTION_STATUS}==True07>>>>... Text Loop (Read Line by line from "Sentence text file" and store it at "READ_SENTENCE_LINE")08>>>>... COUNT_READ_LINES += 1 (Count Read lines from "Sentence text file")09>>>>... IF {COUNT_READ_LINES} == {COUNT_FOUNDED_ARTICLE_FILES}10>>>>>... Write Text File {READ_SENTENCE_LINE} to file {NEW_ARTICLE_FILENAME} (with "Append option" = true)11>>>>>... Write Text File {READ_ARTICLE_LINE} to file {NEW_ARTICLE_FILENAME} (with
"Append option" = true)
12>>>>>... Break13>>><... END IF14>>><... End Loop
15>>> ELSE (INSERTION_STATUS==False)16>>>>... Write Text File
{READ_ARTICLE_LINE}
to file {NEW_ARTICLE_FILENAME}
(with
"Append option" = true)17>><... End IF18>< END LOOP (Read from Article File)19< End Loop (Found "Article Files") //---------------------------------------------------------- ------. you can choose any variable name you like! also at above lines, I write simple algorithm to show you how you can use those loops and I did not write a full code for you! (for instance, some variables should set to 0 or false before/after some conditions or maybe you should add some extra conditions...). But about "Insertion point":First Option (Insert sentence at the beginning of article)----------------------------------------------------------. you can use a Boolean variable to do this. Just create it (for example FIRST_LINE) before "04" line with "True" value.. at "05>>>" line place an "IF" section by this condition:> IF {First_Line}== True>> FIRST_LINE= False>> INSERTION_STATUS= True> End IFSecond Option (Insert sentence before 4th line)
--------------------------------------------------
. At text files each line will end with "carriage return (CR)" (Enter Key). "Text Loop" command at RT, read a line that ended with CR. Each paragraph end with CR, so in fact each paragraph with too many lines can be only one line! To found that, at windows OS, you can open text files with Notepad and then turn of "Word Warp" option from "Format" menu of Notepad.. Ok! base on your infoz! each Article files start with a title line then an empty line and then first paragraph. some thing like this://----------------------Article Title<CR><CR>First Paragraph<CR>Second Paragraph<CR>....//----------------------. therefor, base on above sample, If we read 4 lines at "04>> Text
Loop" line, we will reach to Insertion point! to do that, you will need to create a numerical variable (a Counter) before line "04>> Text
Loop" with 0 value. ( INSERTION_POINT_COUNTER). at "05>>>" line place these codes:> INSERTION_POINT_COUNTER += 1> IF {INSERTION_POINT_COUNTER} == 4 >> INSERTION_STATUS= True
> End IF. Ok, that's should be all you need!?Good LuckIgImAx