Editor scritp

BlitzPlus Forums/BlitzPlus Beginners Area/Editor scritp

Yue(Posted 2013) [#1]
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


Addi(Posted 2013) [#2]
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


Yue(Posted 2013) [#3]
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.


Floyd(Posted 2013) [#4]
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



Yue(Posted 2013) [#5]
@Floyd Thanks you!!

Now I have something to work on and try to continue.


ziggy(Posted 2013) [#6]
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.


Yue(Posted 2013) [#7]
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.


Yue(Posted 2013) [#8]
Ok no problem :D




rickychus(Posted 2013) [#9]
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!


Hotshot2005(Posted 2013) [#10]
SO you making own Script Editor and that really cool :)