Author Topic: ShellExecute problem  (Read 5533 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
ShellExecute problem
« on: August 10, 2012, 11:22:56 AM »
I have try run - compile process with
ShellExecute api but program simply crush...
declaration:
Code: [Select]
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
and under sub:
Code: [Select]
Sub doCompile
int flen=255
string dir
GetCDirectory(255,dir)
'ShellExecute(hwnd AS INT,lpOperation AS STRING,lpFile AS STRING,lpParameters AS STRING,lpDirectory AS STRING,nShowCmd AS INT),INT
print fR
ShellExecute(0,"open",fR,"gxo2.exe"+"-c",dir,1)



End Sub

Peter

  • Guest
Re: ShellExecute problem
« Reply #1 on: August 10, 2012, 11:40:03 AM »
Hi Aurel,

Give your correct path in !

Code: [Select]
%SW_SHOWNORMAL = 1

! ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (sys hwnd, string lpOperation, lpFile, lpParameters, lpDirectory, sys nShowCmd) as sys

ShellExecute(0, 0, "d:/oxygenbasic o38", 0, 0, SW_SHOWNORMAL)
ShellExecute(0, "explore", "d:/oxygenbasic o38", 0, 0, SW_SHOWNORMAL)

print "huhu"


Peter

  • Guest
Re: ShellExecute problem
« Reply #2 on: August 10, 2012, 12:01:03 PM »
once more:

Code: [Select]
ShellExecute(0, "find", "d:/oxygenbasic o38", 0, 0, 0)

Aurel

  • Guest
Re: ShellExecute problem
« Reply #3 on: August 10, 2012, 12:11:08 PM »
Hi Peter...
Hmmm something is strange to me becuse all examples i have found
need operation "open"...
Do you test this with some editor?
As i say i would like to add in scintilla edit test compile option
and i think that main problem is directory path ::)
I would try with GetCurrentDirectoryA(len,string) oh my i am totally confused this days ::)

Aurel

  • Guest
Re: ShellExecute problem
« Reply #4 on: August 10, 2012, 12:41:08 PM »
this way work in others but looks that not in oxygen...
Code: [Select]
Sub doOpen
INT hsize=0
'string fR
dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

title="Open File... "
hwnd=0
fR = FileDialog(dir,filter,title,0,0,"txt")

SendMessage edit1,WM_SETTEXT,0,strptr(fR)
 tx =  Getfile fR
hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
SendMessage hsci,SCI_SETTEXT,hsize+1,strptr(tx)

End Sub
'*************************************************************
Sub doCompile
Dim sSave As String
'create a buffer
sSave = String(255, 0)
GetCurrentDirectory(255,sSave)
'show current directory
print sSave
'show full path to file
print fR
ShellExecute(0,"open","\gxo2.exe","-c"+chr(34)+fR+chr(34),sSave,1)



End Sub

Peter

  • Guest
Re: ShellExecute problem
« Reply #5 on: August 10, 2012, 12:58:10 PM »
Hi Aurel,

This works!

Code: [Select]
ShellExecute(0, byval 0, "d:/", 0, 0, SW_SHOWNORMAL)   'or "open"


Peter

  • Guest
Re: ShellExecute problem
« Reply #6 on: August 10, 2012, 01:09:41 PM »
and this runs !

Code: [Select]
ShellExecute(0,"open","d:/oxygenbasic o38/iup.exe",0,0,1)

Charles Pegge

  • Guest
Re: ShellExecute problem
« Reply #7 on: August 10, 2012, 06:44:37 PM »
Hi Aurel,

Use "" or null for empty parameters.

Code: OxygenBasic
  1. /*
  2. HINSTANCE ShellExecute(
  3.   __in_opt  HWND hwnd,
  4.   __in_opt  LPCTSTR lpOperation,
  5.   __in      LPCTSTR lpFile,
  6.   __in_opt  LPCTSTR lpParameters,
  7.   __in_opt  LPCTSTR lpDirectory,
  8.   __in      INT nShowCmd
  9. );
  10.  
  11.  
  12. operation:
  13. explore
  14. find
  15. open
  16. print
  17. NULL
  18.  
  19. ShowCmd:
  20. SW_HIDE (0)
  21. SW_MAXIMIZE (3)
  22. SW_MINIMIZE (6)
  23. SW_RESTORE (9)
  24. SW_SHOW (5)
  25. SW_SHOWDEFAULT (10)
  26. SW_SHOWMAXIMIZED (3)
  27. SW_SHOWMINIMIZED (2)
  28. SW_SHOWMINNOACTIVE (7)
  29. SW_SHOWNA (8)
  30. SW_SHOWNOACTIVATE (4)
  31. SW_SHOWNORMAL (1)
  32. */
  33.  
  34. ! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
  35. (sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys
  36.  
  37. ShellExecute null,"open","gxo2.exe","t.o2bas","",1
  38. 'ShellExecute null,"open","gxo2.exe","t.o2bas",null,1
  39.  
  40.  

Charles
« Last Edit: August 10, 2012, 06:50:11 PM by Charles Pegge »

Aurel

  • Guest
Re: ShellExecute problem
« Reply #8 on: August 11, 2012, 10:58:35 AM »
After searching and looking everywhere why not work i look again into EB code
and oxyedit.
I know that something is crazy about this api but i don't espect so much crazy
like this time... ::)
It looks that this work...
Code: [Select]
'************************************************************

Sub doOpen

'string fR
dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

title="Open File... "
hwnd=0
fR = FileDialog(dir,filter,title,0,0,"txt")

SendMessage edit1,WM_SETTEXT,0,strptr(fR)
 tx =  Getfile fR
SendMessage hsci,SCI_SETTEXT,0,strptr(tx)
'bstring = ""

End Sub
'*************************************************************
Sub doCompile
' fR -> file Request
print "DOCOMPILE:" + fR
int sRet
'ShellExecute(hwnd ,lpOperation ,lpFile , lpParameters, lpDirectory, nShowCmd)
sRet=ShellExecute 0, "open", "gxo2","-c" + fR , "", 5
'
If sRet > 0 And sRet <> 2
print "Compiled!... "
End If

End Sub


So i can say first time editor produced by Oxygen can compile oxygen code into
executable,right?.. ;)
Ok there is just add new subroutine which parse path and run program...

Charles Pegge

  • Guest
Re: ShellExecute problem
« Reply #9 on: August 11, 2012, 11:54:54 AM »
The Oxide demo uses CreateProcess.

CreateProcess is a little more complicated. I did not know about ShellExecute

Code: OxygenBasic
  1.         s=GetText hw
  2.         if len(s) then Exec o2dir+"gxo2.exe",s,fi
  3. ....
  4.  
  5.   function DOS(string s)
  6.   ======================
  7.   string c
  8.   STARTUPINFO infs
  9.   PROCESS_INFORMATION infp
  10.   if s then c="cmd.exe /c" else c="cmd.exe"
  11.   CreateProcess null,c+s,0,0,0,0,0,0,@infs,@infp
  12.   CloseHandle infp.hProcess
  13.   CloseHandle infp.hThread
  14.   end function
  15.  
  16.  
  17.   function Exec(string c,s,a)
  18.   ===========================
  19.   STARTUPINFO infs
  20.   PROCESS_INFORMATION infp
  21.   if s="" then exit function
  22.   string d=c
  23.   if a then
  24.     d+=" "+a
  25.     putfile a,s
  26.   end if
  27.   CreateProcess c,d,0,0,0,0,0,0,@infs,@infp
  28.   CloseHandle infp.hProcess
  29.   CloseHandle infp.hThread
  30.   end function
  31.  
  32.  

Charles

Aurel

  • Guest
Re: ShellExecute problem
« Reply #10 on: August 11, 2012, 12:22:46 PM »
Hi Charles..
Yes ShellExecute is simple and i know about this because EB command SYSTEM is a wrapper for
ShellExecute.
Yes CreateProcess is a complicated but maybe is better becuse watch process and after can run program
i guess...

Frankolinox

  • Guest
Re: ShellExecute problem
« Reply #11 on: April 04, 2013, 12:56:13 AM »
hello. I am working on an own sci editor (step by step) and did some progresses. Here's working all fine on basis of old good "SciEditor.o2bas" with "exec(string s)" function and the text buffer for compiling is working good as expected.

but if I want to include (add) a new compile/run button with "shellexecute..." function that's not working here.

I am wondering where the "shellexecute" function should get the text buffer for compiling?

Code: [Select]
ShellExecute null,"open","gxo2.exe","t.o2bas","",1  
this should working but not here. and my second question: at the end of the new "AsciEdit" example there's a number of "5". what's that good for?

1)
Code: [Select]
ShellExecute null,"open","/gxo2.exe","","",5   '?

2)
Code: [Select]
Sub doCompile
' fR -> file Request
print "DOCOMPILE:" + fR
int sRet
'ShellExecute(hwnd ,lpOperation ,lpFile , lpParameters, lpDirectory, nShowCmd)
sRet=ShellExecute 0, "open", "gxo2","-c" + fR , "", 5
'
If sRet > 0 And sRet <> 2
print "Compiled!... "
End If


that's a piece of aurel. but I am wondering where the text file get to read for compiling?

I am at work so my exy scieditor example file I haven't at my pc, perhaps I will send new post at the afternoon, evening.

best regards, frank
« Last Edit: April 04, 2013, 01:04:37 AM by Frankolinox »

Charles Pegge

  • Guest
Re: ShellExecute problem
« Reply #12 on: April 04, 2013, 02:29:38 AM »
Hi Frank,
Doees this example help?

! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
(sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys

ShellExecute null,"open","..\..\gxo2.exe","t.o2bas","",1


Aurel

  • Guest
Re: ShellExecute problem
« Reply #13 on: April 04, 2013, 05:47:55 AM »
Quote
ShellExecute null,"open","..\..\gxo2.exe","t.o2bas","",1
No ,this not work for me ...
So Frank...
If your scieditor exe is in same folder where is gxo2.exe compiler ..
ShellExecute (0,"open","\gxo2.exe",filenamePath,"",5)
If your editor exe  is NOT in same folder where is gxo2 compiler you must
set proper path,ok?

i do this in global scope:
Code: [Select]
STRING fName
char tx[500000]
string gxName="\gxo2.exe"
char cdPath[256]
GetCurrentDir 256,cdPath
cdPath = cdPath + gxName
MsgBox cdPath , "Compiler Path...OK!"

then under subroutine:
Code: [Select]
SUB doCompile
'MsgBox (fName,"OK")
IF fName = ""
MsgBox "File Not Open!","Error::File"
Return
End If
int sRet

'(sys hwnd, string lpOperation, lpFile, lpParameters, lpDirectory, sys nShowCmd) as sys
ShellExecute(0,"open",cdPath,"-c" + fName,"" , 5)
'sRet = ShellExecute 0,"open","/gxo2.exe","-c "+fR,sSave,1 print str(sRet)

END SUB

and then here is RUN subroutine:
Code: [Select]
SUB doRun
STRING exepath=""
INT dotpos=0
dotpos=INSTR(fName,".")
exepath=Mid$(fName,1,dotpos-1)
exepath=exepath + ".exe"
'MESSAGEBOX 0,"path:"+exepath,"OK"
ShellExecute(0,"open", exepath, "","" , 5)
END SUB

I hope this will help... :)
And yes ShellExecute do not contain any text buffer JUST strings (full paths)...

Frankolinox

  • Guest
Re: ShellExecute problem
« Reply #14 on: April 08, 2013, 12:26:18 AM »
thank you charles and aurel for your help.

a) charles, your line is working here fine for "shellexecute" function if I specify the name of the oxygenfile for 100 per Cent correctly.
for example: "mytest.o2bas"

b) aurel your example is working too with your Asci Editor, no problem, I have understood these things.

aa) the "gxo2.exe" file I have now in same folder for testing as the oxy example.

Code: [Select]
! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
(sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys

ShellExecute null,"open","gxo2.exe","mytest.o2bas","",1

but... ab) where does oxygen knows what file has to be executed or compiled? if I am using instead of correct file name "mytest1.o2bas" the shellexecute doesn't work, the file is empty (error message appears) or cannot be found. Now how I can say oxygen with "shellexecute" function "please compile or execute the file that's open or saved?" I wanted to prevent to show the open or savefile dialog. If I am saving the file before and using "exec..." function like in "OxiIdeUtil.inc" that's not a problem because the file and whole content (text buffer) was caught and executed as I wished.

below working example for a test only with:

old "sciEdit.o2bas" example:

Code: [Select]
$ Filename"XsciEditTest.exe"
include "RTL32.inc"
Include "awinh.inc"
#lookahead ' for procedures


sys win
INT winstyle
INT button0,button1,button2,button3,button4,button5,button6,button7,button8
INT edit1,edit2,edit3
INT Lbox,static1,static2,static3,hsci
INT ed1ID,ed2ID,ed3ID
INT b0ID,b1ID,b2ID,b3ID,b4ID,b5ID,b6ID,b7ID,b8ID,b9ID,b10ID
INT LboxID = 300
INT st1ID,st2ID
int x,y,w,h
INT reID
b0ID=99
b1ID=100
b2ID=101
b3ID=102
b4ID=103
b5ID=104
b6ID=105
b7ID=106
b8ID=107

'-----------------
ed1ID=200
ed2ID=201
ed3ID=202
'----------------
st1ID=350
st2ID=351
st3ID=352
'##### SCINTILLA CONSTANTS ###################################
sciID=400  'scintilla ID
INT hlibsci,hsci 'scintilla handlers

% SCE_OB_DEFAULT = 0
% SCE_OB_LINECOMMENT = 1
% SCE_OB_BLOCKCOMMENT = 2
% SCE_OB_NUMBER = 3
% SCE_OB_KEYWORD = 4
% SCE_OB_TYPE = 5
% SCE_OB_SETID = 6
% SCE_OB_PREPROCESSOR = 7
% SCE_OB_STRING = 8
% SCE_OB_OPERATOR = 9
% SCE_OB_IDENTIFIER = 10
% SCE_OB_LABEL = 11
% SCE_OB_ASM = 12

% SCLEX_OBASIC = 40

% SCI_SETLEXER = 4001
% SCI_STYLESETFORE = 2051
% SCI_STYLESETBACK = 2052
% SCI_STYLECLEARALL = 2050
% SCI_SETKEYWORDS = 4005
% SCI_STYLESETFONT = 2056
% SCI_STYLESETSIZE = 2055
% SCI_STYLESETBOLD = 2053
% SCI_SETMARGINWIDTHN = 2242
% SCI_SETMARGINTYPEN = 2240
% SCI_SETMARGINSENSITIVEN = 2246
% SCI_SETSELBACK = 2068
% SCI_GOTOLINE = 2024
% SCI_LINELENGTH = 2350
% SCI_GETLINE = 2153
% SCI_GETLINECOUNT = 2154
% SCI_GETCURLINE= 2027
% SCI_SCROLLCARET=2169
% SCI_GOTOPOS=2025
% SCI_GETTEXT = 2182
% SCI_SETTEXT = 2181
% SCI_GETTEXTLENGTH = 2183

% SCI_CLEAR=2180
% SCI_CLEARALL=2004
% SCI_BRACEBADLIGHT=2352
% SCI_BRACEHIGHLIGHT=2351
% SCI_BRACEMATCH=2353
% SCI_GETSELECTIONEND=2145
% SCI_SETSELECTIONEND=2144
% SCI_SETCARETLINEVISIBLE=2096
% SCI_SETCARETFORE = 2069
% SCI_SETCARETLINEBACK = 2098
% SCI_SCROLLCARET=2169
% SCI_UNDO = 2176
% SCI_CUT = 2177
% SCI_COPY = 2178
% SCI_PASTE = 2179

% SC_MARGIN_SYMBOL = 0
% SC_MARGIN_NUMBER = 1
% SCI_SETMARGINMASKN = 2244

! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
(sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys

'ShellExecute null,"open","..\..\gxo2.exe","t.o2bas","",1

'init color strings
bSTRING sciblue,scired,scibrown
Gosub oxyKeywords
'- tview -------------
INT htv,tvID
tvID = 500
'loadbmp
'##################################################
INT bmpB0,bmpB1,bmpB2,bmpB3,bmpB4,bmpB5,bmpB6,bmpB7,bmpB8
bmpB0 = LoadImage(0,"data/btNew.bmp",0,30,30,16)
bmpB1 = LoadImage(0,"data/btOpen.bmp",0,30,30,16)
bmpB2 = LoadImage(0,"data/btSave.bmp",0,30,30,16)
bmpB3 = LoadImage(0,"data/btUndo.bmp",0,30,30,16)
bmpB4 = LoadImage(0,"data/btCut.bmp",0,30,30,16)
bmpB5 = LoadImage(0,"data/btCopy.bmp",0,30,30,16)
bmpB6 = LoadImage(0,"data/btPaste.bmp",0,30,30,16)
bmpB7 = LoadImage(0,"data/btCompile.bmp",0,30,30,16)
bmpB8 = LoadImage(0,"data/btRun.bmp",0,30,30,16)
'##################################################
x=100:y=100:w=640:h=480
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
'create window **************************************************
win = SetWindow("SciEdit Test",x,y,w,h,0,winstyle,&Main)
'****************************************************************

'create buttons ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'NEW
button0 = SetButton(win,4,4,32,32,"",0x50000080,0x200,b0ID)
SendMessage button0 , BM_SETIMAGE, 0, bmpB0
'OPEN
button1 = SetButton(win,38,4,32,32,"O",0x50000080,0x200,b1ID)
SendMessage button1 , BM_SETIMAGE, 0, bmpB1
'SAVE
button2 = SetButton(win,74,4,32,32,"",0x50000080,0x200,b2ID)
SendMessage button2 , BM_SETIMAGE, 0, bmpB2
'UNDO
button3 = SetButton(win,110,4,32,32,"",0x50000080,0x200,b3ID)
SendMessage button3 , BM_SETIMAGE, 0, bmpB3
'CUT
button4 = SetButton(win,146,4,32,32,"",0x50000080,0x200,b4ID)
SendMessage button4 , BM_SETIMAGE, 0, bmpB4
'COPY
button5 = SetButton(win,180,4,32,32,"",0x50000080,0x200,b5ID)
SendMessage button5 , BM_SETIMAGE, 0, bmpB5
'PASTE
button6 = SetButton(win,216,4,32,32,"",0x50000080,0x200,b6ID)
SendMessage button6 , BM_SETIMAGE, 0, bmpB6
'COMPILE
button7 = SetButton(win,252,4,32,32,"",0x50000080,0x200,b7ID)
SendMessage button7 , BM_SETIMAGE, 0, bmpB7
'RUN
button8 = SetButton(win,286,4,32,32,"",0x50000080,0x200,b8ID)
SendMessage button8 , BM_SETIMAGE, 0, bmpB8

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create single-line edit control
edit1 = SetEditBox(win,160,54,466,23,"edit 1",0x50004000,0x200,ed1ID)

'create listbox ===================================================
INT lbx,lby,lbw,lbh
lbx=10:lby=54:lbw=144:lbh=386
Lbox = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140,0x200,LboxID)
'=================================================================
'create static control
static2 = SetStatic(win,10,40,188,13,"Scintilla control in OxygenBasic by Aurel",0,0,st1ID)
'set sci dimensions
INT rx,ry,rw,rh
rx=160:ry=80:rw=466:rh=360

'--------------------------------------------------------------------
'---------------------------------------------------------------------
'Create Scintilla control ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INT hlibsci,hsci,i
hlibsci = LoadLibrary "SciLexer.dll"
'print str(hlibsci)
INT rx,ry,rw,rh,ext,sci_style
rx=160: ry=80 : rw=466 : rh=360 : ext=0x200
sci_style =  WS_CHILD|WS_VISIBLE|ES_SUNKEN
hsci = CreateWindowEx(ext,"Scintilla","",sci_style,rx,ry,rw,rh,win,sciID,0,0)
UpdateWindow hsci
'basic setings...
SENDMESSAGE(hsci, SCI_SETLEXER, SCLEX_OBASIC, 1)
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_DEFAULT,100)
'set sci backColor
SENDMESSAGE(hsci, SCI_STYLESETBACK,32,RGB(235,240,241))
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set font
For i = 0 to 12
SENDMESSAGE (hsci, SCI_STYLESETFONT, i, "Courier New")
SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 9)
Next i
'set keyword colors
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 3,scibrown) :'darkred
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, sciblue ):'blue
 'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)

'--------------------------------------------------------------------
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_LINECOMMENT,rgb(0,120,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_BLOCKCOMMENT, rgb(0,120,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_NUMBER,RGB(0,0,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_KEYWORD,RGB(200,0,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_TYPE,RGB(0,0,200)) :'keywords
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_SETID,rgb(160,0,0)):'orange/to dark blue
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_PREPROCESSOR,rgb(220,0,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_STRING, 0x880088 )
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_OPERATOR,rgb(0,0,180))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_IDENTIFIER, 0x000000 )
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_LABEL,rgb(0,0,0))
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_ASM, 0x555555 )

'ControlFont(hsci,16,400,0,"Courier New")

'->->->->->->->->->->->->->->->->->->
sys bRet
  '
  WHILE GetMessage (&wm,0,0,0)<>0
  TranslateMessage &wm
  DispatchMessage &wm
 WEND
'<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-

Function Main(byval hWnd as long,byval wMsg as long, byval wParam as long,byval lparam as sys) as sys callback

SELECT wMsg
'----------------------------

CASE WM_DESTROY
PostQuitMessage 0
'------------------------------------------
case WM_SIZE
GetSize(win,x,y,w,h)
MoveWindow(hsci,160,80,(w-rw/2)+64,(h-56)-32 ,1)
MoveWindow(edit1,160,54,(w-rw/2)+64,23 ,1)
MoveWindow(Lbox,10,54,lbw,(h-56)-8 ,1)
'-------------------------------------------------------------
'-------------------------------------------------------------
CASE WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message

Select controlID
  CASE b0ID
If notifycode=0
'clear
SendMessage hsci,WM_SETTEXT,0,""
End If

  CASE b1ID
If notifycode=0  
Gosub doOpen
fnParser()
End If

  CASE b2ID
    If notifycode=0
'doSave    
        print "doRUN"
        'ShellExecute null,"open","..\..\gxo2.exe","t.o2bas","",1
        'ShellExecute null,"open","gxo2.exe","*.o2bas","",1
dorun
        End If

 CASE b3ID
If notifycode=0
'doUndo
End If

 CASE b4ID
If notifycode=0
'doCut
End If

 CASE b5ID
If notifycode=0
'doCopy
End If




End Select
'-----------------------------------------------------
END SELECT

FUNCTION = DefWindowProc hwnd,wMsg,wParam,lParam

END FUNCTION

SUB doRun()
STRING fName
STRING exepath=""
INT dotpos=0
dotpos=INSTR(fName,".")
exepath=Mid$(fName,1,dotpos-1)
exepath=exepath + ".exe"
'MESSAGEBOX 0,"path:"+exepath,"OK"
ShellExecute(0,"open", "gxo2.exe", "scintTest.o2bas","" , 1)
END SUB


'************************************************************

Sub doOpen
INT hsize=0
string fR
dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

title="Open File... "
hwnd=0
fR = FileDialog(dir,filter,title,0,0,"txt")

SendMessage edit1,WM_SETTEXT,0,strptr(fR)
 tx =  Getfile fR
hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
SendMessage hsci,SCI_SETTEXT,hsize+1,strptr(tx)

End Sub
'*************************************************************
SUB fnParser
STRING o2script[1024] 'string array
STRING i$,txt,d$=" "
STRING GW1,GW2
INT smax,start,lineNum,iLen,bo,ipos
start=0
smax = Sendmessage hsci,SCI_GETLINECOUNT, 0, 0

'parse line by line >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FOR lineNum = start TO smax

int Pos=0
int EPos=0
int SPos=0
int WC=0

'get-line ........................................................

iLen = SendMessage hsci,SCI_LINELENGTH,lineNum,0    'get line length
o2script[lineNum] = String(iLen," ")                'set buffer space
Sendmessage hsci,SCI_GETLINE, lineNum, strPtr(o2script[lineNum])
'test ///////////////////////////////
'print "LINE:" + o2script[lineNum]
'///////////////////////////////////
o2script[lineNum] = Ltrim(o2script[lineNum])
'--------------------------------------------
WC = 1
Pos = InStr(1,o2script[lineNum], d$)
    While Pos > 0
        WC = WC + 1
Pos = InStr(pos+1,o2script[lineNum], d$)
    Wend
'test wc------------------------------------------
'print WC
IF wc>0      
    SPos = 1      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW1 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW1:"+GW1
END IF
'--------------------------------------------------
IF wc>1      
    SPos=EPos+2      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW2 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW2:"+GW2
END IF

'test string & add to listbox
'/// SUB ///
IF Ucase(GW1) = "SUB"
'remove bracket ((((((((((((((((
bo = Instr (GW2,"(")
'print str(Len(GW2))
'print "BO:"+str(bo)
 IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
 END IF
i$ = "SUB:" + GW2
If ipos<>0 then ipos++
SendMessage Lbox,LB_ADDSTRING,ipos,i$
END IF
'/// FUNCTION ///
IF (Ucase(GW1) = "FUNCTION") And (Left(GW2,1)<>"=") And (Mid(GW1,9)<>"=")
bo = Instr (GW2,"(")
 IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
 END IF
i$ = "FN:" + GW2
If ipos<>0 then ipos++
SendMessage Lbox,LB_ADDSTRING,0,i$
END IF
GW1="":GW2=""

NEXT

END SUB


'///////////////////////////////////////
SUB oxyKeywords

'blue
sciblue="enum operator dim const local static global declare function sub method end if then else elseif endif "
sciblue=sciblue+"endsel do while enddo endwhile wend exit continue operation operations select case for to step next "
sciblue=sciblue+"goto gosub methods return block scope indexbase lib library extern that this "
sciblue=sciblue+"readstate writestate deff type val ltrim rtrim lcase ucase space left mid instr "
sciblue=sciblue+"asc len chr str hex print ellipse rgb sendmessage "
sciblue=sciblue+"with "
sciblue=sciblue+"noinit "
sciblue=sciblue+"byval "
sciblue=sciblue+"byref "
sciblue=sciblue+"economy "
sciblue=sciblue+"fpu "
sciblue=sciblue+"cpu "
sciblue=sciblue+"noprec "
sciblue=sciblue+"include "
sciblue=sciblue+"define "
sciblue=sciblue+"typedef "
sciblue=sciblue+"includepath "
sciblue=sciblue+"lookahead "
sciblue=sciblue+"view "
sciblue=sciblue+"endv "
sciblue=sciblue+"version "
sciblue=sciblue+"getmemory "
sciblue=sciblue+"freememory "
sciblue=sciblue+"getprocaddress "
sciblue=sciblue+"copy0 "
sciblue=sciblue+"copy00 "
sciblue=sciblue+"copyn "
sciblue=sciblue+"copy "
sciblue=sciblue+"mbox "
sciblue=sciblue+"comparestr "
'----------------------------
sciblue=sciblue+"alias macro as "
sciblue=sciblue+"incl "
sciblue=sciblue+"semicolon "
sciblue=sciblue+"indexers "
sciblue=sciblue+"retn "
sciblue=sciblue+"offset "
sciblue=sciblue+"skip "
sciblue=sciblue+"with "
sciblue=sciblue+"dataspace "
sciblue=sciblue+"data "
sciblue=sciblue+"o2 "
sciblue=sciblue+"bind "
sciblue=sciblue+"defs "
sciblue=sciblue+"def "
sciblue=sciblue+"struct "
sciblue=sciblue+"class "
sciblue=sciblue+"var "
sciblue=sciblue+"asm "
sciblue=sciblue+"o2h "
sciblue=sciblue+"librarypath "
sciblue=sciblue+"file "
sciblue=sciblue+"quote "
sciblue=sciblue+"union "
sciblue=sciblue+"leaf "
sciblue=sciblue+"autodim "
sciblue=sciblue+"minormajor "
sciblue=sciblue+"alert "
sciblue=sciblue+"pragma "
sciblue=sciblue+"unique "
sciblue=sciblue+"console "
sciblue=sciblue+"elif "
sciblue=sciblue+"fi "
sciblue=sciblue+"ifdef "
sciblue=sciblue+"ifndef "
sciblue=sciblue+"undef "
sciblue=sciblue+"undefine "
sciblue=sciblue+"blockdepth "
sciblue=sciblue+"new "
sciblue=sciblue+"del "
sciblue=sciblue+"terminate "
sciblue=sciblue+"freestrings "
sciblue=sciblue+"freelibs "
sciblue=sciblue+"inherits "
sciblue=sciblue+"of "
sciblue=sciblue+"from "
sciblue=sciblue+"has "
sciblue=sciblue+"export "
sciblue=sciblue+"external "
sciblue=sciblue+"com "
sciblue=sciblue+"virtual "
sciblue=sciblue+"endselect "
sciblue=sciblue+"load "
sciblue=sciblue+"and "
sciblue=sciblue+"or "
sciblue=sciblue+"xor "
sciblue=sciblue+"stdcall "
sciblue=sciblue+"cdecl "
sciblue=sciblue+"ms64 "
sciblue=sciblue+"pascal "
sciblue=sciblue+"not "
sciblue=sciblue+"once "
sciblue=sciblue+"public "
sciblue=sciblue+"private "
sciblue=sciblue+"strptr "
'darkred - brown
scibrown=scibrown+"void "
scibrown=scibrown+"byte "
scibrown=scibrown+"astring "
scibrown=scibrown+"pstring "
scibrown=scibrown+"bstring "
scibrown=scibrown+"char "
scibrown=scibrown+"zstring "
scibrown=scibrown+"wstring "
scibrown=scibrown+"bstring2 "
scibrown=scibrown+"zstring2 "
scibrown=scibrown+"asciiz "
scibrown=scibrown+"short "
scibrown=scibrown+"int "
scibrown=scibrown+"integer "
scibrown=scibrown+"float "
scibrown=scibrown+"single "
scibrown=scibrown+"sys "
scibrown=scibrown+"double "
scibrown=scibrown+"quad "
scibrown=scibrown+"word "
scibrown=scibrown+"dword "
scibrown=scibrown+"qword "
scibrown=scibrown+"uint "
scibrown=scibrown+"__int8 "
scibrown=scibrown+"__int16 "
scibrown=scibrown+"__int32 "
scibrown=scibrown+"__int64 "
scibrown=scibrown+"int8_t "
scibrown=scibrown+"int16_t "
scibrown=scibrown+"int32_t "
scibrown=scibrown+"int64_t "
scibrown=scibrown+"uint8_t "
scibrown=scibrown+"uint16_t "
scibrown=scibrown+"uint32_t "
scibrown=scibrown+"uint64_t "
scibrown=scibrown+"any "
scibrown=scibrown+"sys"
scibrown=scibrown+" bool "
scibrown=scibrown+"signed "
scibrown=scibrown+"unsigned "
scibrown=scibrown+"string "
scibrown=scibrown+"long "

END SUB

there must be an alternative way to work with "shellexecute" and "gxo2.exe" for compiling/running the script example without saving of open the current file.

best regards, frank