Editor scritp
BlitzPlus Forums/BlitzPlus Beginners Area/Editor scritp
| ||
window = CreateWindow("Fenster", 100, 100, 600, 400, Desktop(), 3) textarea = CreateTextArea(0, 0, ClientWidth(window), ClientHeight(window), window) Cadena$ = "visual" Repeat If WaitEvent() = $803 Then End ID = EventSource() If ID = textarea temp = Instr(Lower$(TextAreaText$(textarea)), Cadena$) End If If temp Then FormatTextAreaText textarea, 255, 0, 0, 8, temp - 1, Len(Cadena$) End If End If Forever I'm trying to highlight the syntax for a script editor, however though it happens the first time, I can not happens a second time if the word appears again, any suggestions |
| ||
the problem you have is that instr starts to search for the word at the beginning of the sentence. so it will always break at the first "visual" and it will never reach the second one and so it will never return the pos of it. the funtion has a 3rd parameter which you can use to say to it at which position it should start to search |
| ||
I'm trying to find out if you have a function that returns me posicón status pointer, this would be the starting point for new searches to highlight the writing, at least it is an idea but not really to do. |
| ||
Start looking at the first position after the substring you just found.s$ = "HelloGoodbyeHelloGoodbyeHelloGoodbyeHelloGoodbye" t$ = "Goodbye" p = 1 Repeat p = Instr( s, t, p ) If p = 0 Then Exit Print "Found " + t + " at position " + p p = p + Len( t ) Forever WaitKey |
| ||
@Floyd Thanks you!! Now I have something to work on and try to continue. |
| ||
If you want to make a script highlighting, you should considere creating a tokenizer for the script text. That is, read char by char, organize them in words (tokens) and assign each token a color once you've decided its kind. |
| ||
t$ = "If" p = 0 Repeat S$ = TextAreaText(TextScript%) p = Instr( s, t$, p ) ;If p = 0 Then Exit Print "Found " + t + " at position " + p If P Then p = p + Len(t) FormatTextAreaText TextScript, 255, 0, 0, 1, P-Len(t$)-1, Len(T$) End If Forever ![]() It seems that it works correctly, however I fail to recognize me minusuclas is case, ie if or IF typing or If, to highlight the color. Any suggestions. |
| ||
Ok no problem :D![]() |
| ||
Hi, I think you need the compound conditions. IF a = "if" OR a = "IF" OR a = "If" OR... etc. sure I'm late :D See you! |
| ||
SO you making own Script Editor and that really cool :) |