1. My Old Dos .ex Kaleidoscope programme
- Posted by Selgor Jul 26, 2010
- 1466 views
- Last edited Aug 02, 2010
Hello
Selgor here
I am trying to bring my old dos programme into the windows exw stage.
No errors are given.
But it will not "start"
I do not know much about set handlers.
or appinit function.
It worked "beautifully" in the "old dos .ex"
Recoded drawLine
But that is all
Main programme is Draw_it
Any help
In anticipation
Cheers
Selgor.
Code :=>
----------------------------------------------------- -------------------- Kaleidoscope ALL ------------- -------------------- Version 2.09 ------------- ----------------------------------------------------- ---------------------------------------- Kullar & of course Kcol define ------------------------ set pen etc ......... ???? include win32lib.ew without warning --include graphics.e --include machine.e --include mouse.e --include truecolr.e --use_vesa(1) --if graphics_mode(18) then end if -- constant MainWindow = -- create( Window, "Click to show another bitmap", 0, Default, Default, 400, 400, 0 ) -- draw a red line --drawLine( TheWindow, 10, 10, 40, 40 ) constant Win = create( Window, "Kal", 0, Default, Default, Default,Default, 0 ) -- WinMain( PopWin, Normal ) --setPenColor(Win, Red ) --sequence kcol -- kcol={}-- = {Black,NavyBlue,Blue,BrightBlue,ForestGreen,Green,Cyan,SkyBlue, -- BrightGreen,BrightCyan,DarkGray,EggPlant,Red,Magenta,DarkBrown,Olive,Gray, -- Brown,LightGray,Purple,White,BrightRed,BrightMagenta,Violet, -- Orange,Pink,Yellow,Parchment,BrightWhite} atom a,b,c,d,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3, x,y,x1,y1,xx,yy,xx1,yy1,xxx,yyy,xxx1,yyy1,xxxx,yyyy,xxxx1,yyyy1, lt,tp,rt,bt,lt1,tp1,rt1,bt1,lt2,tp2,rt2,bt2,lt3,tp3,rt3,bt3, kount,kcount,in,kcol kount=0 kcol=rand(16) kcount=0 -- in=init_VESA() lt=0 tp=0 bt=300 rt=405 lt1=225 tp1=0 bt1=300 rt1=630 lt2=0 tp2=180 bt2=480 rt2=405 lt3=225 tp3=180 bt3=480 rt3=630 x=235 x1=205 y=80 y1=220 xx=392 xx1=422 yy=80 yy1=220 xxx=235 xxx1=205 yyy=400 yyy1=260 xxxx=392 xxxx1=422 yyyy=400 yyyy1=260 a=1 b=1 c=2 d=1 a1=a b1=b c1=c d1=d a2=a b2=b c2=c d2=d a3=a b3=b c3=c d3=d -- setPenColor( TheWindow, Red ) --procedure dun() -- mouse_pointer(0) -- mouse_events(2) -- if sequence(get_mouse()) then -- abort(1) -- elsif get_key()=27 then -- abort(1) -- end if --end procedure procedure random() end procedure --procedure kullar() -- if kcol >= 16 then kcol = rand(16) -- elsif kount= 6 then kcol = rand(16) -- elsif kount=60 then kcol+=1 kount=0 -- end if --end procedure procedure val() x-=a y-=b x1-=c y1-=d xx+=a1 yy-=b1 xx1+=c1 yy1-=d1 xxx-=a2 yyy+=b2 xxx1-=c2 yyy1+=d2 xxxx+=a3 yyyy+=b3 xxxx1+=c3 yyyy1+=d3 end procedure procedure xyopp() if x<lt or x>rt then a=-a end if if y<tp or y>bt then b=-b end if if x1<lt or x1>rt then c=-c end if if y1<tp or y1>bt then d=-d end if end procedure procedure xyopp2() if xx<lt1 or xx>rt1 then a1=-a1 end if if yy<tp1 or yy>bt1 then b1=-b1 end if if xx1<lt1 or xx1>rt1 then c1=-c1 end if if yy1<tp1 or yy1>bt1 then d1=-d1 end if end procedure procedure xyopp3() if xxx<lt2 or xxx>rt2 then a2=-a2 end if if yyy<tp2 or yyy>bt2 then b2=-b2 end if if xxx1<lt2 or xxx1>rt2 then c2=-c2 end if if yyy1<tp2 or yyy1>bt2 then d2=-d2 end if end procedure procedure xyopp4() if xxxx<lt3 or xxxx>rt3 then a3=-a3 end if if yyyy<tp3 or yyyy>bt3 then b3=-b3 end if if xxxx1<lt3 or xxxx1>rt3 then c3=-c3 end if if yyyy1<tp3 or yyyy1>bt3 then d3=-d3 end if end procedure procedure stall() for i=1 to 1500000 do end for end procedure procedure draw_it() for i= 1 to 65 by .1 do kount+=1 --kullar() drawLine(Win,x+a,y+b,x1+c,y1+d) drawLine(Win,xxx+a2,yyy+b2,xxx1+c2,yyy1+d2) drawLine(Win,xx+a1,yy+b1,xx1+c1,yy1+d1) drawLine(Win,xxxx+a3,yyyy+b3,xxxx1+c3,yyyy1+d3) if get_key()=27 then abort(0) end if --dun() stall() val() xyopp() xyopp2() xyopp3() xyopp4() end for kcount+=1 clear_screen() end procedure while get_key() != 27 do draw_it() end while setHandler(Win,w32HActivate, routine_id("draw_it")) --include w32Start.ew -- draw_it() WinMain( Win, SW_MAXIMIZE ) ---------- setHandler ....... which ??? ------------ maybe function appinit() ???? \\
2. Re: My Old Dos .ex Kaleidoscope programme
- Posted by DanM Jul 26, 2010
- 1415 views
- Last edited Aug 02, 2010
Hello
Selgor here
I am trying to bring my old dos programme into the windows exw stage.
No errors are given.
But it will not "start"
I do not know much about set handlers.
or appinit function.
It worked "beautifully" in the "old dos .ex"
Recoded drawLine
But that is all
Main programme is Draw_it
Any help
In anticipation
Cheers
Selgor.
Code :=>
----------------------------------------------------- -------------------- Kaleidoscope ALL ------------- -------------------- Version 2.09 ------------- ----------------------------------------------------- ---------------------------------------- Kullar & of course Kcol define ------------------------ set pen etc ......... ???? include win32lib.ew without warning --include graphics.e --include machine.e --include mouse.e --include truecolr.e --use_vesa(1) --if graphics_mode(18) then end if -- constant MainWindow = -- create( Window, "Click to show another bitmap", 0, Default, Default, 400, 400, 0 ) -- draw a red line --drawLine( TheWindow, 10, 10, 40, 40 ) constant Win = create( Window, "Kal", 0, Default, Default, Default,Default, 0 ) -- WinMain( PopWin, Normal ) --setPenColor(Win, Red ) --sequence kcol -- kcol={}-- = {Black,NavyBlue,Blue,BrightBlue,ForestGreen,Green,Cyan,SkyBlue, -- BrightGreen,BrightCyan,DarkGray,EggPlant,Red,Magenta,DarkBrown,Olive,Gray, -- Brown,LightGray,Purple,White,BrightRed,BrightMagenta,Violet, -- Orange,Pink,Yellow,Parchment,BrightWhite} atom a,b,c,d,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3, x,y,x1,y1,xx,yy,xx1,yy1,xxx,yyy,xxx1,yyy1,xxxx,yyyy,xxxx1,yyyy1, lt,tp,rt,bt,lt1,tp1,rt1,bt1,lt2,tp2,rt2,bt2,lt3,tp3,rt3,bt3, kount,kcount,in,kcol kount=0 kcol=rand(16) kcount=0 -- in=init_VESA() lt=0 tp=0 bt=300 rt=405 lt1=225 tp1=0 bt1=300 rt1=630 lt2=0 tp2=180 bt2=480 rt2=405 lt3=225 tp3=180 bt3=480 rt3=630 x=235 x1=205 y=80 y1=220 xx=392 xx1=422 yy=80 yy1=220 xxx=235 xxx1=205 yyy=400 yyy1=260 xxxx=392 xxxx1=422 yyyy=400 yyyy1=260 a=1 b=1 c=2 d=1 a1=a b1=b c1=c d1=d a2=a b2=b c2=c d2=d a3=a b3=b c3=c d3=d -- setPenColor( TheWindow, Red ) --procedure dun() -- mouse_pointer(0) -- mouse_events(2) -- if sequence(get_mouse()) then -- abort(1) -- elsif get_key()=27 then -- abort(1) -- end if --end procedure procedure random() end procedure --procedure kullar() -- if kcol >= 16 then kcol = rand(16) -- elsif kount= 6 then kcol = rand(16) -- elsif kount=60 then kcol+=1 kount=0 -- end if --end procedure procedure val() x-=a y-=b x1-=c y1-=d xx+=a1 yy-=b1 xx1+=c1 yy1-=d1 xxx-=a2 yyy+=b2 xxx1-=c2 yyy1+=d2 xxxx+=a3 yyyy+=b3 xxxx1+=c3 yyyy1+=d3 end procedure procedure xyopp() if x<lt or x>rt then a=-a end if if y<tp or y>bt then b=-b end if if x1<lt or x1>rt then c=-c end if if y1<tp or y1>bt then d=-d end if end procedure procedure xyopp2() if xx<lt1 or xx>rt1 then a1=-a1 end if if yy<tp1 or yy>bt1 then b1=-b1 end if if xx1<lt1 or xx1>rt1 then c1=-c1 end if if yy1<tp1 or yy1>bt1 then d1=-d1 end if end procedure procedure xyopp3() if xxx<lt2 or xxx>rt2 then a2=-a2 end if if yyy<tp2 or yyy>bt2 then b2=-b2 end if if xxx1<lt2 or xxx1>rt2 then c2=-c2 end if if yyy1<tp2 or yyy1>bt2 then d2=-d2 end if end procedure procedure xyopp4() if xxxx<lt3 or xxxx>rt3 then a3=-a3 end if if yyyy<tp3 or yyyy>bt3 then b3=-b3 end if if xxxx1<lt3 or xxxx1>rt3 then c3=-c3 end if if yyyy1<tp3 or yyyy1>bt3 then d3=-d3 end if end procedure procedure stall() for i=1 to 1500000 do end for end procedure procedure draw_it() for i= 1 to 65 by .1 do kount+=1 --kullar() drawLine(Win,x+a,y+b,x1+c,y1+d) drawLine(Win,xxx+a2,yyy+b2,xxx1+c2,yyy1+d2) drawLine(Win,xx+a1,yy+b1,xx1+c1,yy1+d1) drawLine(Win,xxxx+a3,yyyy+b3,xxxx1+c3,yyyy1+d3) if get_key()=27 then abort(0) end if --dun() stall() val() xyopp() xyopp2() xyopp3() xyopp4() end for kcount+=1 clear_screen() end procedure while get_key() != 27 do draw_it() end while setHandler(Win,w32HActivate, routine_id("draw_it")) --include w32Start.ew -- draw_it() WinMain( Win, SW_MAXIMIZE ) ---------- setHandler ....... which ??? ------------ maybe function appinit() ???? \\
selgor,
try these fixes:
1. in your main procedure, draw_it, declare it instead like this:
procedure draw_it(integer self, integer event, sequence params)
2. comment out or remove your test for escape key under your draw_it procedure
3. in draw_it, remove clear_screen()
Those fixes make it run for me, don't know if you need any more to make it work as you want it or not.
Dan M.
3. Re: My Old Dos .ex Kaleidoscope programme
- Posted by dcole Jul 26, 2010
- 1427 views
- Last edited Aug 02, 2010
Hello Selgor.
I got your code to work with the following changes:
procedure draw_it(integer self,integer event,sequence params) for i = 1 to 65 by 1 do
You can use .1 but you have to put floor in there somewhere because pStartX won.t take fractions.
Don Cole
4. Re: My Old Dos .ex Kaleidoscope programme
- Posted by DerekParnell (admin) Jul 27, 2010
- 1307 views
- Last edited Aug 02, 2010
Can you keep the Subject text down to a reasonable size please? The subject is not the message.
I am trying to bring my old dos programme into the windows exw stage.
No errors are given.
But it will not "start"
I do not know much about set handlers ...
The approach to programming for DOS is totally different than the one for Windows. With a GUI, you will be working in an event-based environment. That is, your application will be responding to events and so you structure your code into small procedures that each deal with just one type of event. Your application will have no control of the order that events happen so you cannot assume that any of your procedures or variables will be used in any specific sequence.
Also, when it comes to graphics, the better method is to do all your drawing onto a canvas which is not actually visible, and at the approriate event, copy the canvas to the visible part of your application.
In this example you have supplied, the Window's background is the place that the user will see the drawing take place.
Here is some code that seems to do what you wanted ...
----------------------------------------------------- -------------------- Kaleidoscope ALL ------------- -------------------- Version 2.09 ------------- ----------------------------------------------------- include win32lib.ew without warning constant Win = create( Window, "Kal", 0, Default, Default, Default,Default, 0 ) -- Create a canvas to draw upon. constant canvas = create( Pixmap, "", 0, 0, 0, 1, 1, 0 ) constant Timer = 1 constant colors = { Black, NavyBlue, Blue, BrightBlue, ForestGreen, Green, Cyan, SkyBlue, BrightGreen, BrightCyan, DarkGray, Eggplant, Red, Magenta, DarkBrown, Olive, Gray, Brown, LightGray, Purple, White, BrightRed, BrightMagenta, Violet, Orange, Pink, Yellow, Parchment, BrightWhite } atom a,b,c,d,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3, x,y,x1,y1,xx,yy,xx1,yy1,xxx,yyy,xxx1,yyy1,xxxx,yyyy,xxxx1,yyyy1, lt,tp,rt,bt,lt1,tp1,rt1,bt1,lt2,tp2,rt2,bt2,lt3,tp3,rt3,bt3, kount,kcount,in,kcol integer segment procedure init_vars() kount=0 kcol=rand(length(colors)) kcount=0 segment = 0 lt=0 tp=0 bt=300 rt=405 lt1=225 tp1=0 bt1=300 rt1=630 lt2=0 tp2=180 bt2=480 rt2=405 lt3=225 tp3=180 bt3=480 rt3=630 x=235 x1=205 y=80 y1=220 xx=392 xx1=422 yy=80 yy1=220 xxx=235 xxx1=205 yyy=400 yyy1=260 xxxx=392 xxxx1=422 yyyy=400 yyyy1=260 a=1 b=1 c=2 d=1 a1=a b1=b c1=c d1=d a2=a b2=b c2=c d2=d a3=a b3=b c3=c d3=d clearWindow(canvas) end procedure procedure kullar() if kcol >= length(colors) then kcol = rand(length(colors)) else if remainder(segment, 3) = 0 then kcol = rand(length(colors)) end if end if end procedure procedure val() x-=a y-=b x1-=c y1-=d xx+=a1 yy-=b1 xx1+=c1 yy1-=d1 xxx-=a2 yyy+=b2 xxx1-=c2 yyy1+=d2 xxxx+=a3 yyyy+=b3 xxxx1+=c3 yyyy1+=d3 end procedure procedure xyopp() if x<lt or x>rt then a=-a end if if y<tp or y>bt then b=-b end if if x1<lt or x1>rt then c=-c end if if y1<tp or y1>bt then d=-d end if end procedure procedure xyopp2() if xx<lt1 or xx>rt1 then a1=-a1 end if if yy<tp1 or yy>bt1 then b1=-b1 end if if xx1<lt1 or xx1>rt1 then c1=-c1 end if if yy1<tp1 or yy1>bt1 then d1=-d1 end if end procedure procedure xyopp3() if xxx<lt2 or xxx>rt2 then a2=-a2 end if if yyy<tp2 or yyy>bt2 then b2=-b2 end if if xxx1<lt2 or xxx1>rt2 then c2=-c2 end if if yyy1<tp2 or yyy1>bt2 then d2=-d2 end if end procedure procedure xyopp4() if xxxx<lt3 or xxxx>rt3 then a3=-a3 end if if yyyy<tp3 or yyyy>bt3 then b3=-b3 end if if xxxx1<lt3 or xxxx1>rt3 then c3=-c3 end if if yyyy1<tp3 or yyyy1>bt3 then d3=-d3 end if end procedure integer stopped stopped = 0 procedure WinKey(integer id, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then stopped = not stopped elsif parms[1] = VK_ENTER then init_vars() stopped = 0 end if end procedure setHandler(Screen, w32HKeyDown, routine_id("WinKey")) procedure draw_it(integer id, integer event, sequence parms) -- On each tick of the timer, I draw the next segment of the picture. if stopped then -- Stopped, so do nothing. return end if if segment >= 65 then -- Maximum number of segments already drawn, -- so do nothing. return end if segment += 1 kount+=1 kullar() setPenColor(canvas, colors[kcol]) drawLine(canvas,x+a,y+b,x1+c,y1+d) drawLine(canvas,xxx+a2,yyy+b2,xxx1+c2,yyy1+d2) drawLine(canvas,xx+a1,yy+b1,xx1+c1,yy1+d1) drawLine(canvas,xxxx+a3,yyyy+b3,xxxx1+c3,yyyy1+d3) val() xyopp() xyopp2() xyopp3() xyopp4() if segment = 65 then kcount+=1 end if -- Force the window to be redrawn. repaintFG(Win) end procedure setHandler(Win, w32HTimer, routine_id( "draw_it" )) procedure start_it(integer id, integer event, sequence parms) -- Start the timer ticking at 10 times per second setTimer( Win, Timer, 100 ) end procedure setHandler(Win, w32HActivate, routine_id("start_it")) procedure paint_it(integer id, integer event, sequence parms) -- Whenever the window needs to be repainted, -- copy the picture to the window. copyBlt(Win, 0, 0, canvas) -- Refresh the 'help' text. wPuts( {Win, 10, 10}, "ESC to pause/continue ENTER to restart") end procedure setHandler(Win, w32HPaint, routine_id("paint_it")) procedure resizing(integer id, integer event, sequence parms) -- Whenever the window changes size, I need to resize the canvas to -- match the new window size. setCtlSize(canvas, parms[2], parms[3]) init_vars() stopped = 0 end procedure setHandler(Win, w32HResize, routine_id("resizing")) WinMain( Win, SW_MAXIMIZE )
5. Re: My Old Dos .ex Kaleidoscope programme
- Posted by dcole Jul 28, 2010
- 1355 views
- Last edited Aug 02, 2010
Hello Signor,
I'm not sure where you want put clear_screen.
I think this is what you want.
----------------------------------------------------- include win32lib.ew without warning include graphics.e include machine.e --if graphics_mode(18) then end if constant Win = create( Window, "Kal", 0, 100, 100, 640,520, 0 ) constant s = getClientRect(Win) --setPenColor(Win, Red ) atom rgb rgb=getPixel(Win,10,10)--a random point before any drawing atom a,b,c,d,a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3, x,y,x1,y1,xx,yy,xx1,yy1,xxx,yyy,xxx1,yyy1,xxxx,yyyy,xxxx1,yyyy1, lt,tp,rt,bt,lt1,tp1,rt1,bt1,lt2,tp2,rt2,bt2,lt3,tp3,rt3,bt3, kount,kcount,kcol kount=0 kcol=rand(16) kcount=0 lt=0 tp=0 bt=300 rt=405 lt1=225 tp1=0 bt1=300 rt1=630 lt2=0 tp2=180 bt2=480 rt2=405 lt3=225 tp3=180 bt3=480 rt3=630 x=235 x1=205 y=80 y1=220 xx=392 xx1=422 yy=80 yy1=220 xxx=235 xxx1=205 yyy=400 yyy1=260 xxxx=392 xxxx1=422 yyyy=400 yyyy1=260 a=1 b=1 c=2 d=1 a1=a b1=b c1=c d1=d a2=a b2=b c2=c d2=d a3=a b3=b c3=c d3=d procedure val() x-=a y-=b x1-=c y1-=d xx+=a1 yy-=b1 xx1+=c1 yy1-=d1 xxx-=a2 yyy+=b2 xxx1-=c2 yyy1+=d2 xxxx+=a3 yyyy+=b3 xxxx1+=c3 yyyy1+=d3 end procedure procedure xyopp() if x<lt or x>rt then a=-a end if if y<tp or y>bt then b=-b end if if x1<lt or x1>rt then c=-c end if if y1<tp or y1>bt then d=-d end if end procedure procedure xyopp2() if xx<lt1 or xx>rt1 then a1=-a1 end if if yy<tp1 or yy>bt1 then b1=-b1 end if if xx1<lt1 or xx1>rt1 then c1=-c1 end if if yy1<tp1 or yy1>bt1 then d1=-d1 end if end procedure procedure xyopp3() if xxx<lt2 or xxx>rt2 then a2=-a2 end if if yyy<tp2 or yyy>bt2 then b2=-b2 end if if xxx1<lt2 or xxx1>rt2 then c2=-c2 end if if yyy1<tp2 or yyy1>bt2 then d2=-d2 end if end procedure procedure xyopp4() if xxxx<lt3 or xxxx>rt3 then a3=-a3 end if if yyyy<tp3 or yyyy>bt3 then b3=-b3 end if if xxxx1<lt3 or xxxx1>rt3 then c3=-c3 end if if yyyy1<tp3 or yyyy1>bt3 then d3=-d3 end if end procedure procedure stall() for i=1 to 1500000 do end for end procedure procedure clearScreen() setPenColor(Win,rgb) drawRectangle( Win, w32True, s[1],s[2],s[3],s[4] ) end procedure procedure draw_it(integer self, integer event, sequence params) for i= 1 to 65 by .1 do doEvents(0)--this checks for keystrokes kount+=1 setPenColor(Win,Red) drawLine(Win,x+a,y+b,x1+c,y1+d) drawLine(Win,xxx+a2,yyy+b2,xxx1+c2,yyy1+d2) drawLine(Win,xx+a1,yy+b1,xx1+c1,yy1+d1) drawLine(Win,xxxx+a3,yyyy+b3,xxxx1+c3,yyyy1+d3) stall() val() xyopp() xyopp2() xyopp3() xyopp4() clearScreen() end for kcount+=1 end procedure setHandler(Win,w32HActivate, routine_id("draw_it")) procedure close(integer self,integer event,sequence params) if params[1]=27 then--esc closeWindow(Win) end if end procedure setHandler(Win,w32HKeyDown,routine_id("close")) WinMain( Win, Normal )
Don Cole
6. Re: My Old Dos .ex Kaleidoscope programme
- Posted by dcole Jul 28, 2010
- 1363 views
- Last edited Aug 02, 2010
Hello
Selgor here
I do not know much about set handlers.
Sigor,
If you have not done so download Judith's IDE.
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=ide
When you open it a window appears on the left hand side that has tabs PropertyList and Events.
First click (in the Form Design window) the Contol you want to handle e.g, the Window. Then select the Event.
A Code Editor window will open with most of the code writen out for you.
Don Cole
7. Re: My Old Dos .ex Kaleidoscope programme
- Posted by Selgor Jul 30, 2010
- 1258 views
- Last edited Aug 02, 2010
Hello Don,
Selgor here
Many thanks for the "clear screen"
All works very well.
But, Derek has written programme in EXW format.
Some modification is necessary to keep it running.
And I have worked this out.
So I will post the programme in full in the next day.
And thank you for the IDE tip .. Judith.
Will download and look .
Hope I do not need another degree to decipher it I use Context .
Don, you are a tower of strength.
Thank you for all your help.
Post prog soon .
Take it for a spin .. hope you enjoy.
Cheers.
Selgor.