Search String
BlitzPlus Forums/BlitzPlus Programming/Search String
| ||
Hello All. This code below is giving me trouble. I'm trying to search for selected words within a string and print them in another colour. This works for the word AND but use the word they and it gives me errors. Where am I going wrong with this? :GWID=1300:GHEI=620:Graphics GWID,250,16,2:FH=FontHeight():FW=FontWidth():LO$=CurrentDir$(): ILP=1:BLP=1:TFW=GWID-ED:LX=0:LY=FH*4:NN$="and":LN=Len(NN$) S$="and I saw thrones, and they sat upon them, and judgment was given unto them: and I saw the souls of them that were beheaded for the witness of Jesus, and for the word of God, and which had not worshipped the beast, neither his image, neither had received his mark upon their foreheads, or in their hands; and they lived and reigned with Christ a thousand years.~" ;and I saw thrones, and they sat upon them, and judgment was given unto them: and I saw the souls of them that were beheaded for the witness of ;Jesus, and for the word of God, and which had not worshipped the beast, neither his image, neither had received his mark upon their foreheads, ;or in their hands; and they lived and reigned with Christ a thousand years.~" .NLI While (Len(TM$)<((TFW/FW)-9)) ; TSP=Instr(Mid$(S$,1,TFW/FW)," "):If TSP=0 And Instr(Mid$(S$,TFW/FW),"~") Then TM$=TM$+Mid$(S$,TFW/FW):Exit TSP=Instr(Mid$(S$,1,BLP)," "):If TSP=0 And Instr(Mid$(S$,BLP),"~") Then TM$=TM$+Mid$(S$,BLP):Exit TM$=TM$+Mid$(S$,BLP,Instr(Mid$(S$,BLP)," ")) ILP=Instr(Mid$(S$,BLP)," "):BLP=BLP+ILP:;Print ILP:HALT Wend While Right$(TM$,1)<>" " TM$=Left$(TM$,Len(TM$)-1):BLP=BLP-1 Wend ;Print TM$:HALT(99) If Instr(Upper$(TM$),Upper$(NN$)) ARW=Instr(Upper$(TM$),Upper$(NN$)):ELP=1:Text 1250,20+NLI*FH,ARW:NLI=NLI+1:TS=Instr(TM$," "):Print "TS: "+TS While ARW<>0 If ARW=1 TS=Instr(TM$," "):HLT$=Left$(TM$,TS):ELP=ELP+TS:HL=1:If ARW=1 Then ARIO=ARIO+1;If TS>=Len(TM$) Then Exit TM$=Mid$(TM$,TS+1):Text LX,LY,HLT$::LX=LX+RSW(HLT$) ElseIf ARW>1 NHT$=Left$(TM$,ARW-1):ELP=ELP+ARW:HL=0:;If TS>=Len(TM$) Then Exit TM$=Mid$(TM$,ARW):Text LX,LY,NHT$:LX=LX+RSW(NHT$) EndIf ARW=Instr(Upper$(TM$),Upper$(NN$)): Wend EndIf Text LX,LY,TM$:LX=LX+RSW(TM$):LX=0:LY=LY+FH:SOV=SOV+1:If SOV>2 Then Text LX,LY+FH,TM$:HALT(99) TM$="":Goto NLI This has been edited. I have the algorithm going completely through but it does not exit properly for some reason. It's something simple that I'm overlooking Thanks for the help |
| ||
The Function RSW() just returns the stringwidth() of a string |
| ||
That's really messy and difficult to follow especially since you have so many array(?) names that are undefined and unhelpful subroutine labels/variables. Where's the rest of the code? |
| ||
Hey Mark I rewrote the code taking the arrays out. It almost works now but somewhere I missed something simple. |
| ||
Updated and rewritten |