1. Making smaller bound executables
- Posted by fizzpop at nospam.icon.co.za Apr 13, 2004
- 406 views
Hi, has anybody else noticed that if you take a DOS32 source .ex, rename it to .exw and use bindw instead of bind, your resulting .exe is much smaller? In my case, 76k versus 188k (on Win2k sp4) I'm using Eu 2.4, but have seen this in earlier Eu releases too. Here is some example code, note only simple includes. -- onhour v1.0 Jan 2004 -- programming language: euphoria v2.4, see www.rapideuphoria.com -- description: Run the command line argument to this program, -- every hour, on the hour -- environment: MS-DOS 5.0 or above, Windows NT 4.0 /95/98 or above -- with trace with type_check without profile without warning include misc.e include get.e include msgbox.e -- sequence cmdline, arg1, arg2, moan integer parserc, execs, logfile atom msgbox procedure parse_cmdline() integer i1 parserc = 0 puts(logfile,"\nOnHour program no copyright") cmdline = command_line() -- get the command line from the OS i1 = length(cmdline) -- number of arguments with call included if length(cmdline) != 4 then moan = "\nInvalid number of arguments!\n" moan = moan & "\n EXAMPLE: 'onhour -v c:\\mydir\\mycmd.bat'\n" moan = moan & "OR, 'onhour -s pgmname.exe'" puts(logfile,moan) close(logfile) msgbox = message_box(moan,"OnHour fatal error",0) abort(8) end if -- trace(1) arg1 = cmdline[3] -- first logical argument if compare(arg1,"-v") = 0 then parserc = 1 puts(logfile,"\nonhour program is in verbose mode\n") end if if compare(arg1,"-s") = 0 then parserc = 2 puts(logfile,"\nonhour program is in silent mode\n") end if if parserc = 0 then moan = "\nThe first argument (parameter) to this program" moan = moan & " needs to be '-v' or '-s' " moan = moan & "\nfor VERBOSE or SILENT mode.\n" moan = moan & "\n EXAMPLE: 'onhour -v c:\\mydir\\mycmd.bat'\n" moan = moan & "OR, 'onhour -s pgmname.exe'" puts(logfile,moan) msgbox = message_box(moan,"OnHour fatal error",0) abort(8) end if arg2 = cmdline[4] -- should be the filename to execute execs = 0 end procedure procedure countdown() -- wait for 1st hour boundry sequence s1, s2, s3 integer i1, i2, i3, i4 s1 = date() i1 = s1[4] -- hour i2 = s1[5] -- minite i3 = i2 - 60 i3 = i3 * -1 i4 = i3 * 60 s2 = sprintf("%2d",i3) s3 = "\nThe first execution of " s3 = s3 & arg2 & " will start in " & s2 & " minites. \n" puts(logfile,s3) sleep(i4) end procedure procedure confirm_work() -- check that bat or exe exists sequence s1 integer i1 i1 = open(arg2,"rb") -- open it for reading if i1 = -1 then moan = "\nFatal error! Cannot find '" & arg2 moan = moan & "' . Do not use long filename conventions.\n" moan = moan & "This argument cannot be a command; it must" moan = moan & " be a type .BAT or .EXE or a .COM" puts(logfile,moan) close(logfile) msgbox = message_box(moan,"OnHour fatal error",0) abort(4) end if close(i1) end procedure procedure doit() sequence s1, s2, s3, s4, s5 integer i1, i3, i4 i1 = 60 * 60 -- seconds to an hour execs = execs + 1 s1 = sprintf("%5d",{execs}) s2 = date() i3 = s2[4] -- hour i4 = s2[5] -- minite s3 = sprintf("%02d",i3) s4 = sprintf("%02d",i4) sleep(i1) if parserc = 1 then -- verbose s5 = "At " & s3 & ":" & s4 & " Running the " & s1 s5 = s5 & " execution of " & arg2 & "\n" puts(logfile,s5) end if system(arg2,2) end procedure procedure uselog() sequence s1, s2 s1 = getenv("TMP") if length(s1) < 5 then s1 = getenv("TEMP") end if if length(s1) < 5 then moan = "\nUnable to discover TMP or TEMP directory. " moan = moan & "Please set this environmental variable first!" msgbox = message_box(moan,"OnHour fatal error",0) abort(8) end if s1 = s1 & "\\onhour.log" logfile = open(s1,"w") if logfile = -1 then moan = "\nCannot open " & s1 & " file for writing." msgbox = message_box(moan,"OnHour fatal error",0) abort(8) end if -- puts(1,"\nLogfile is " & s1 ) end procedure procedure main() uselog() parse_cmdline() confirm_work() countdown() while 1 do -- infinite loop doit() end while end procedure main()
2. Re: Making smaller bound executables
- Posted by "Juergen Luethje" <j.lue at gmx.de> Apr 13, 2004
- 404 views
Guest wrote: > posted by: fizzpop at nospam.icon.co.za > > Hi, has anybody else noticed that if you take a DOS32 source .ex, > rename it to .exw and use bindw instead of bind, your resulting .exe > is much smaller? > In my case, 76k versus 188k (on Win2k sp4) > I'm using Eu 2.4, but have seen this in earlier Eu releases too. I think the main reason might be -- at least if the source code is not too big like in your example --, that using 'bindw' your program is bound to the file "pdexw.exe" (72 k in Eu 2.4), while using 'bind' the program is bound to "pdex.exe" (about 182 k in Eu 2.4). [code snipped] Regards, Juergen -- /"\ ASCII ribbon campain | |\ _,,,---,,_ \ / against HTML in | /,`.-'`' -. ;-;;,_ X e-mail and news, | |,4- ) )-,_..;\ ( `'-' / \ and unneeded MIME | '---''(_/--' `-'\_)