|
Adding characters to the middle of a string: msg#00287windows.autoit.user
Aloha gang Still playing with my text2html I took a bunch of this code from my indexer so some of it may not apply One part I'm having to do is figure out how to add the link code to the middle of a text string So far the idea I have is to do a stringmid and fileappend each char separately, then when I get to the char number the link started at insert the beginning of the link code then the end when I reach the ending char of the link insert the anchor Can anyone think of an easier way to do this I'll put the condumdrum of my working script below Rick SetBatchLines, 150 setenv,htmlcode,http:/abcdefghijklmnopqrstuvwxyz_-.ABXDEFGHIJKLMNOPQRSTUVWXYZ123456789 setenv,emailchars,http:/abcdefghijklmnopqrstuvwxyz_-.ABXDEFGHIJKLMNOPQRSTUVWXYZ123456789@ start: MsgBox, 1, Ricks Text2Html, Select the text file to convert IfMsgBox, CANCEL, exit FileSelectFile, textfile, 1,%a_scriptdir% ifequal,errorlevel,1.goto,start MsgBox, 1, Ricks Text2Html, You have selected %textfile% IfMsgBox, CANCEL, goto,start setenv,newhtml,%textfile% ifexist,%newhtml%,SplashTextOn, 500, 300, Ricks Text2Hrml, %newhtml% exists and will be deleted in 20 seconds \nTo exit this program right mouse click on the A then left mouse click on exit in the lower right hand corner of your screen \nVist My Website at http://KirkhamsMartialArts.8m.com splashtextoff RunWait,%comspec% /c del %newhtml%,,hide stringreplace,newhtml,newhtml,.txt,.htm makehead: ;FileAppend, <Text>, <Filename> FileAppend, <HTML> , %newhtml% FileAppend, <HEAD> , %newhtml% FileAppend, <TITLE> Ricks Text2Html</TITLE> \n , %newhtml% FileAppend, <STYLE TYPE="text/css"> \n , %newhtml% ;FileAppend, A:link { \n , %newhtml% ;FileAppend, COLOR: red; FONT-FAMILY: Arial \, Helvetica; FONT-SIZE: 25px; \n , %newhtml% ;FileAppend, FONT-WEIGHT: bold; \n , %newhtml% ;FileAppend, TEXT-DECORATION: none; background:yellow; \n , %newhtml% ;FileAppend, } \n , %newhtml% ;FileAppend, A:active { \n , %newhtml% ;FileAppend, COLOR:red; TEXT-DECORATION: none; FONT-SIZE: 25px; background:yellow; \n , %newhtml% FileAppend, } \n , %newhtml% ;FileAppend, A:visited { \n , %newhtml% ;FileAppend, COLOR:red; TEXT-DECORATION: none; FONT-SIZE: 25px; \n , %newhtml% ;FileAppend, background:yellow; \n , %newhtml% ;FileAppend, font-weight:bold; \n , %newhtml% ;FileAppend, } \n , %newhtml% FileAppend, A:hover {COLOR: white ;FONT-SIZE: 25px; \n , %newhtml% FileAppend, TEXT-DECORATION: underline; background: red; FONT-SIZE: 25px; \n , %newhtml% FileAppend, } \n , %newhtml% FileAppend, </STYLE> \n , %newhtml% FileAppend, </HEAD> \n , %newhtml% FileAppend, <BODY> \n , %newhtml% FileAppend, <PRE> \n , %newhtml% SetEnv,count,0 setenv,texcount,1 readlist: ;MsgBox,4096,test,tag=%tag% strip=%strip% EnvAdd,count,1 ;file read routine FileReadLine,textline,%textfile%,%count% IfEqual,errorlevel,1,Goto,done setenv,pcount,1 stringlen.textlinelen,textline setenv,startchar,1 setenv,linklen,1 ifinstring,textline,http://,gosub,anchorpage ifinstring,textline,@,gosub,anchormail fileappend,%textine%\n,%newhtml% goto, readlist readtextline: FileReadLine,intextline,%textline%,%pcount% IfEqual,errorlevel,1,Goto,readlist IfInString, intextline, <title>, goto, outloop ;IfInString, <String Variable>, <Search String>, <Command> EnvAdd,pcount,1 ifequal,pcount,11,goto,readlist Goto,readtextline outloop: setenv,strip,%intextline% Stringtrimleft,strip,strip,7 ;MsgBox,4096,test,tag=%tag% strip=%strip% ;StringGetPos, <Output Variable> , <Input Variable>, <Search Text> IfInString,strip, <,goto,stripright ;IfInString, <String Variable>, <Search String>, <Command> ;goto, writelink stripright: StringGetPos, tag, strip, < StringLeft, strip, strip,%tag% ;MsgBox,4096,test,tag=%tag% strip=%strip% ;StringLeft, <Output Variable> , <Input Variable>, <Number of chars to extract> ;stringtrimright,strip,tag,20 ;StringTrimRight, <Output Variable> , <Input Variable>, <Number of chars to trim> ;MsgBox,4096,test,tag=%tag% strip=%strip% StringReplace,textline,textline,%tpath%, StringReplace,strip,strip,</title>, StringReplace,strip,strip,<title>, StringReplace,strip,strip,title>, StringReplace,strip,strip,itle>, StringReplace,strip,strip,<title, StringReplace,strip,strip,</tit, ;MsgBox,4096,test,%strip% writelink: FileAppend, <P ALIGN="CENTER"><FONT SIZE="+1"><A\n ,%newhtml% FileAppend, HREF="%textline%" target = " Ricks Indexer " >%strip%</A></FONT></P> \n \n,%newhtml% ;MsgBox,4096,test,textline==%textline% strip=%strip% newhtml=%newhtml% ;do my thing here goto, readlist done: FileAppend, <P ALIGN="CENTER"><FONT SIZE="+1"><A\n ,%newhtml% FileAppend, HREF="http://kirkhamsebooks.8m.com" target = " Ricks Index " >http://kirkhamsebooks.8m.com</A></FONT></P> \n \n,%newhtml% FileAppend, <P ALIGN="CENTER"><FONT SIZE="+1"><A\n ,%newhtml% FileAppend, HREF="http://kirkhamsmartialarts.8m.com" target = " Ricks Index " > http://kirkhamsmartialarts.8m.com</A></FONT></P> \n \n,%newhtml% FileAppend, <P ALIGN="CENTER"><FONT SIZE="+1"><A\n ,%newhtml% FileAppend, HREF="http://inhometutoring.8m.com" target = " Ricks Index " >http://InHomeTutoring.8m.com</A></FONT></P> \n \n,%newhtml% FileAppend, </BODY> \n ,%newhtml% FileAppend, </HTML> \n \n,%newhtml% ;MsgBox, 0, Matched, Yes, the search string was not found ;do my thing ;RunWait,%comspec% /c del %textfile%,,hide ;RunWait,%comspec% /c del %tpath%%textfile%,,hide RunWait,%comspec% /c xcopy /y %newhtml% %tpath%,,hide SplashTextOn, 500, 300, Ricks Indexer, %newhtml% is completed and your program or batch file will still run\n%newhtml% has been copied to %tpath% and %tpath% has been deleted from the link so it is now a virtual link\nVist My Website at http://KirkhamsMartialArts.8m.com sleep,20000 Splashtextoff exit anchorpage: ;<A HREF="http://mypage.htm">I am a link</A> ;FileAppend, <A HREF="http://mypage.htm">I am a link</A> \n ,%newhtml% ;StringMid, <Output Variable> , <Input Variable>, <Start char>, <Number of chars to extract> stringmid,link,textline,%startchar%,7 ifequal,link,http://,setenv,startlink,%startchar% ifequal,link,http://,goto,parselink envadd,startchar,1 envadd,linklen,7 ifgreaterorequal,linklen,%textlinelen%,return goto,anchorpage parselink: setenv,startchar2,1 stringmid,link,textline,%startchar%,1 ifnotinstring,htmlcode,%link%,envadd,textlinelen.%linklen% ifnotinstring,htmlcode,%link%,gosub,setanchor setenv,anchor,%anchor%%link% envadd,startchar,1 goto,parselink setanchor: ;<A HREF="http://mypage.htm">I am a link</A> setenv,hyperlink,\<A HREF\=\"%link%\"\>%link%\</A\> ===== http://kirkhamsebooks.tripod.com/RaisingYourChild_in.html http://kirkhamsmartialarts.tripod.com/martialarts_ezine.html http://kirkhamsmartialarts.tripod.com/ebooksvideoscassettes.htm Obesity in Children, Anger Management, Internal Energy Strikes, meditation & More & NOW Raising Your Child to be More Postive and More Confident http://kirkhamsmartialarts.tripod.com/sellmyebooks http://kirkhamsmartialarts.tripod.com/qualifications http://SeriousMartialArtistsOnly.8m.com The Combat Martial Arts Ezine __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ------------------------ Yahoo! Groups Sponsor ---------------------~--> Looking for the latest Free IT White Papers? Visit SearchSecurity.com to access over 500 white papers. Get instant access at SearchSecurity.com Today http://us.click.yahoo.com/ayjvfD/QLNGAA/uitMAA/EGnolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: AutoItList-unsubscribe@xxxxxxxxxxxxxxx Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: QuickQuestion: 00287, Sensei J. Richard Kirkham B.Sc |
|---|---|
| Next by Date: | Re: Re: QuickQuestion: 00287, Armando Miller |
| Previous by Thread: | Re: QuickQuestioni: 00287, Private Name |
| Next by Thread: | Math Functions...: 00287, Private Name |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |