Cheers
Nice list of answers there.
For anyone who is trying to use the 'editbox get line' statement, it doesnt work. What you need to do is use 'window get text' and scan for the line breaks using code similar to this:
codemax = editbox get line count(e1)
string$ = window get text(e1)
X = 0
repeat
inc X, 1
Y = 0
repeat
inc Y, 1
v$ = left$(string$,Y)
v$ = right$(v$,2)
until Y = len(string$) or v$ = Chr$(13) + Chr$(10)
if Y <> len(string$)
codeline(X) = left$(string$,Y-2)
else
codeline(X) = left$(string$,Y)
endif
string$ = right$(string$,len(string$)-Y)
until X = codemax
This should return all lines within the edit box in the array of codeline().
Here is another piece of code I have made but never completed because it was too buggy. It creates a separate editbox along side a previous one which is read only. It then adds line numbers to that box. It functioned fine when adding lines as the algorithm refreshed the line numbers between the top line and bottom line due to the auto scroll not working. Now I get the problem when i scroll back up the main edit box, the line numbers do not follow, and when i begin editing further up the main edit box the line numbers stop interacting.
This function returns the string of line numbers to be used in the number editbox.
function linenumbers()
if len(str$(topline+1)) = 1 then digits$ = "0000" + str$(topline+1)
if len(str$(topline+1)) = 2 then digits$ = "000" + str$(topline+1)
if len(str$(topline+1)) = 3 then digits$ = "00" + str$(topline+1)
if len(str$(topline+1)) = 4 then digits$ = "0" + str$(topline+1)
if len(str$(topline+1)) = 5 then digits$ = "" + str$(topline+1)
digit1 = val(left$(digits$,1))
digits$ = right$(digits$,4)
digit2 = val(left$(digits$,1))
digits$ = right$(digits$,3)
digit3 = val(left$(digits$,1))
digits$ = right$(digits$,2)
digit4 = val(left$(digits$,1))
digits$ = right$(digits$,1)
digit5 = val(left$(digits$,1))
if digit1 <> 0
linenumbers$ = str$(digit1) + str$(digit2) + str$(digit3) + str$(digit4) + str$(digit5)
else
if digit2 <> 0
linenumbers$ = str$(digit2) + str$(digit3) + str$(digit4) + str$(digit5)
else
if digit3 <> 0
linenumbers$ = str$(digit3) + str$(digit4) + str$(digit5)
else
if digit4 <> 0
linenumbers$ = str$(digit4) + str$(digit5)
else
if digit5 <> 0
linenumbers$ = str$(digit5)
else
linenumbers$ = str$(0)
endif
endif
endif
endif
endif
X = 0
repeat
inc X, 1
inc digit5, 1
if digit5 = 10
inc digit4, 1
digit5 = 0
endif
if digit4 = 10
inc digit3, 1
digit4 = 0
endif
if digit3 = 10
inc digit2, 1
digit3 = 0
endif
if digit2 = 10
inc digit1, 1
digit2 = 0
endif
if digit1 <> 0
linenumbers$ = linenumbers$ + split() + str$(digit1) + str$(digit2) + str$(digit3) + str$(digit4) + str$(digit5)
else
if digit2 <> 0
linenumbers$ = linenumbers$ + split() + str$(digit2) + str$(digit3) + str$(digit4) + str$(digit5)
else
if digit3 <> 0
linenumbers$ = linenumbers$ + split() + str$(digit3) + str$(digit4) + str$(digit5)
else
if digit4 <> 0
linenumbers$ = linenumbers$ + split() + str$(digit4) + str$(digit5)
else
if digit5 <> 0
linenumbers$ = linenumbers$ + split() + str$(digit5)
else
linenumbers$ = linenumbers$ + split() + str$(0)
endif
endif
endif
endif
endif
until X = 60
endfunction linenumbers$
Main code for program:
set window on
if check display mode(1024, 768, 32)=1
set window size 1024, 768
set display mode 1024, 768, 32
else
set window size 640, 480
set display mode 640, 480, 32
endif
DIM codeline(1000) AS STRING
GLOBAL codemax AS INTEGER
GLOBAL xmax AS INTEGER
xmax = screen width()
GLOBAL ymax AS INTEGER
ymax = screen height()
sync on : sync rate 60
set window layout 3,1,1
GLOBAL topline AS INTEGER
GLOBAL digit1 AS INTEGER
GLOBAL digit2 AS INTEGER
GLOBAL digit3 AS INTEGER
GLOBAL digit4 AS INTEGER
GLOBAL digit5 AS INTEGER
GLOBAL e1
GLOBAL e2
GLOBAL e3
start bbb gui
windows set font 7,"Arial",0,0,0,0
windows set visibility 1
#include "constants.dba"
GLOBAL dbpro_w
dbpro_w=get dbpro window() : set main window dbpro_w
`dbpro_w2 = make window(desktop width(), desktop height(), "Test", dbpro_w)
w = make window(0,0,desktop width(),desktop height(),"Test",dbpro_w,WS_CHILD)
GLOBAL e1
e1=make editbox(70,0,desktop width()-70,desktop height()-200,ES_MULTILINE||WS_VSCROLL||WS_HSCROLL,w)
windows set font 10,"Arial",0,0,0,0
`e1=make editbox(0,0,desktop width(),desktop height()-200,ES_MULTILINE||WS_VSCROLL||WS_HSCROLL,w)
windows set font 7,"Arial",0,0,0,0
e2=make editbox(0,desktop height()-201,desktop width(),120,ES_MULTILINE||WS_VSCROLL||WS_HSCROLL||ES_READONLY,w)
windows set font 10,"Arial",0,0,0,0
e3=make editbox(0,0,70,desktop height()-200,ES_MULTILINE||ES_READONLY||ES_AUTOVSCROLL||ES_RIGHT,w) `||WS_VSCROLL||WS_HSCROLL
test$ = "Line Total: " + str$(editbox get first visible line(e1)) + split() + "Line Total: " + str$(editbox get line count(e1))
`X = 0
`repeat
` inc X, 1
` V$ = left$(test$,X)
` V$ = right$(V$,2)
` if V$ = split() then end
`until X = len(test$)
`window set text e2, get dir$()
window set text e2, "Line Top: " + str$(editbox get first visible line(e1)) + split() + "Line Total: " + str$(editbox get line count(e1)) + split() + ":" + editbox get line(2,e1) + split() + ":" + str$(editbox get first visible line(e1))
topline = editbox get first visible line(e1)
window set text e3, linenumbers()
maximize window
repeat
close()
menuselect = menu get selected item id()
if returnkey() = 1
topline = editbox get first visible line(e1)
if editbox get first visible line(e1) = topline
window set text e3, linenumbers()
endif
window set text e2, "Line Top: " + str$(editbox get first visible line(e1)) + split() + "Line Total: " + str$(editbox get line count(e1)) + split() + ":" + editbox get line(2,e1) + split() + ":" + str$(editbox get first visible line(e1))
endif
if menuselect = 3 or menuselect = 4
save()
endif
until escapekey() = 1
end
Close and split functions (required):
function split()
split$ = Chr$(13) + Chr$(10)
endfunction split$
function close()
repeat
get event
h=event get handle()
m=event get message()
if h=get main window()
if m=WM_CLOSE
end
`a=make message box("Are you sure you want to quit?","BBB Gui plugin",MB_YESNO)
`if a=IDYES then end bbb gui : end
endif
endif
until m=0
endfunction
Hope this code helps people
EDIT
Also, is syntax highlighting possible or just not started, because I would really love to have it as a feature.