News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Easy GUI Disabling

Started by niox, January 27, 2010, 03:49:03 PM

Previous topic - Next topic

niox

Hey guys
I have coded this application which can be compiled with or without the GUI depending on whether a compile time constant has been set.
It looks like this:

USE_GUI equ 1

Of course i have made the compilation of code many places depending on this constant being set. I like this since it makes it easy for me to disable the GUI quick an easy.

That said, the GUI uses 3 pictures which of course takes up quite a bit of space in the executable. But i have yet to find a way to exclude these pictures from the resources of the executable, depending on the compile time constant (USE_GUI) being set or not.

Excluding it manually is error prone and that isnt good since i might not be the only one to compile this.

Anyone knows how to do this or if its even possible?

thanks

Kind regards
Niox

dedndave

i have seen assembler files that are also batch files that assemble themselves
i forget exactly how they did it - lol
for batch execution, use GOTO to skip over the assembler code text
for assembly, i think they had a COMMENT directive, which is ok - it may generate a single error in the batch file which is ignored
then, you might be able to use a macro called SET
if it is assembling, the macro sets the EQUate
if it is executed as a batch file, SET is a command
something like that - lol

at any rate, you could then have conditional linking that omits the resource file
hope that gives you some ideas to play with   :P

drizz

rc /DUSE_GUI file.rc

file.rc:
#ifdef USE_GUI

#endif

ml /DUSE_GUI file.asm

file.asm:
ifdef USE_GUI

endif
The truth cannot be learned ... it can only be recognized.

jj2007

Hi Niox,

You can use various batch commands to determine if you want to add the resource file. Here is an example that simply checks whether a resource file is present.

REM assuming arg 1 is MyFile.ASM, this strips .ASM from MyFile.ASM
set oRes=%~n1
if NOT exist "%oRes%.rc" (
echo.
if NOT %oRes%==0 (
echo *** %oRes%.rc not found, will try rsrc.rc ***
set oRes=rsrc
)
)

niox

Hey guys. thx alot for your answers.

I think this is what i need to go find a solution.  :)

I might post some additional questions but thx alot so far.

Best regards
Niox

dedndave

i was thinking about what Drizz suggested
it is exactly what you want, only in reverse - lol
you want to modify a statement in the assembler file and alter the batch process

without combining the batch and assembler files, there is one other way i can think of...
most of us use batch files for assembly that redirect the assembler console text into a scratch file for late display
you could use the ECHO directive to place a flag token into the assembler output text
then, write a small EXE that parses that scratch file and searches for the token
the EXE can return an exit code that the batch file can use to branch
it may sound complicated, but the EXE would be fairly simple - and, you only have to write it once   :bg

niox

Quote from: dedndave on January 28, 2010, 04:20:16 PM
i was thinking about what Drizz suggested
it is exactly what you want, only in reverse - lol
you want to modify a statement in the assembler file and alter the batch process

without combining the batch and assembler files, there is one other way i can think of...
most of us use batch files for assembly that redirect the assembler console text into a scratch file for late display
you could use the ECHO directive to place a flag token into the assembler output text
then, write a small EXE that parses that scratch file and searches for the token
the EXE can return an exit code that the batch file can use to branch
it may sound complicated, but the EXE would be fairly simple - and, you only have to write it once   :bg

Except from separate .exe file that was also what i had hoped to do. You might be right creating a seperate .exe is the only way to go. But then my concern is again that this is making it too complicated and will cause problems when other are compiling this.
But i'll look into it :)

Best regards
Niox

Slugsnack

I think this can be done with something like the compile time language in HLA but this is not a feature of MASM or so is my understanding

dedndave

well - it may appear to be too complicated at first glance - i was thinking the same thing
but, the little EXE (as well as the batch file) could easily be distributed with the source
who knows - it may become a tool widely used by others
with a little forethought, it could be made to be a little flexible, opening it to other uses, as well
for example, if the batch file return code was specified in the ASM text,
programmers could use it to do all kinds of things in the batch   :U
things like selecting different resource files for different OS builds, etc

EDIT - it's not a difficult program to write...
read the command line to get the path\filename of the scratch file
open the file and search for a specific string (something like BATCH=3)
return the value (3) in the exit code
if the string is not found, return 0

FORTRANS

Hi,

   Use drizz'es idea with a BATch file?

MakeIt /DUSE_GUI

REM MakeIt.BAT
rc %1 file.rc
ml %1 file.asm

Regards,

Steve

dedndave

hiya Steve
i think the idea was to control the batch process from the assembler file

FORTRANS

Hi Dave,

   Yeah, but if he needs it to be used by others, keep it
simple.  Otherwise your external program may be best
idea.

Cheers,

Steve

dedndave

well - i was going to leave it be, as i had a couple other projects going - lol
but, my brain is burned out on those
maybe i will code this up just to get a break on something easy, then go back to those
i guess it is a sign of age - 10 years ago, i could spend all my spare time coding and not get burned out
maybe it is all the documentation i have to pour through now - lol
i used to sit down and start typing code - no books - no net - slam dunk
i do miss the 16-bit world - i knew my way around so well   :P

dedndave

; BatchNum - by DednDave - Version 1
;
; A Simple Batch File Utility:
; Originally intended for use in assembler batch files, this utility has a number of other uses.
; By using any number of small text files, extremely complex batch processes can be formed.
;
;   I) opens the text file specified on the command line (full drive:\path\filename.ext accepted)
;     1) place ONLY the file drive:\path\filename.ext on the command line
;        extraneous characters will invalidate the filename string
;        this does not apply to standard DOS redirection characters
;        i.e. BatchNum C:\test.txt>nul will work, but the display text is redirected to the NUL device
;     2) if the filename is invalid or the file does not exist, exits with an error message
;        also returns an exit code of 0 (any invalid condition returns 0)
;
;  II) reads up to 8192 bytes from the file
;
; III) searches for the first occurance of the string "BATCH" (must be all capital letters)
;     1) if the string is not found, an exit code value of 0 is returned
;
;  IV) parses the numeric value that follows and returns it as an exit code
;     1) non-numeric characters between elements are ignored (except end of line or end of file)
;     2) after the first numeric digit is found, any non-numeric character terminates parsing
;     3) maximum value is 255
;
;  V) displays the value:
;     BATCHNUM: nnn
;
; All of the following text file examples return an exit code of 255:
;
; BATCH255
; BATCH 255
; BATCH=255
; BATCH = 255
; BATCH Value = 255
; BATCHNUM: 255
; BATCH 1024
;
; Resluting display text:
;
; BATCHNUM: 255
;
; As mentioned above, BatchNum C:\test.txt>nul can be used to silence the displayed value text.

see attached - source included

EDIT - for another little batch utility (an oldie) see this post and the post that follows it...
http://www.masm32.com/board/index.php?topic=13032.msg101106#msg101106