Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3711
Number of posts: 9173

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Macro isn't working... Posted by Sephiroth on 7 Mar 2003 at 8:59 PM
I'm to the point in my server application that I need to change the case of specific letters at times for various reasons. If the server was Windoze-only, I could use strlwr or strupr, but this is being coded on Linux to be ported to Windoze later, and those functions don't exist there. Here are my macros, maybe one of you can figure them out.
#define LOWER(c) ((c) >= 'A' && (c) <= 'Z' ? (c)+'a'-'A' : (c))
#define UPPER(c) ((c) >= 'a' && (c) <= 'z' ? (c)+'A'-'a' : (c))

That is in one of my header files. I may also just be too dang tired and missing something simple elsewhere in my code. Oh well, bed-time. Thanks for the help.

-Sephiroth
Report
Re: Macro isn't working... Posted by seizepuppet on 8 Mar 2003 at 5:33 PM
If you are wanting a macro to change a single character, use
standard c library macros toupper(c) and tolower(c)
If you plan to use the stl, that can do it for both linux
and windoze, or you can loop on the toupper and tolower
for your own c strings.


Report
Re: Macro isn't working... Posted by Sephiroth on 8 Mar 2003 at 10:54 PM
Like I said before, "to*" won't work becuase they need an "unsigned char" variable, which won't work for my needs. I don't know what I was smoking last night, but it must have been good, because I was trying to call the macros like functions, rather than using them in an expression. They work fine.
UPPER(Player[LoginID].Buffer[0]); //Wrong
Player[LoginID].Buffer[0] = UPPER(Player[LoginID].Buffer[0]); //Right

I am currently writing descriptions and setting bonuses for races in the game and testing it out. So far it works flawlessly and generates no errors (except a single recv() error if you disconnect without telling the server you're leaving with a quit or exit command). You can go as far as selecting your race and seeing race descriptions right now. I plan on opening the server with five races and three classes to choose from. In the end, there can be an unlimited number of races and classes, but 5*3=15 possible routes, and if you do a multiclass character you can multiply 15 by 9 to get the total number of opening setups you can choose from. Now if only I found time to code the client...

-Sephiroth

Report
Re: Macro isn't working... Posted by AsmGuru62 on 10 Mar 2003 at 7:17 AM
: Like I said before, "to*" won't work becuase they need an "unsigned char" variable, which won't work for my needs. I don't know what I was smoking last night, but it must have been good, because I was trying to call the macros like functions, rather than using them in an expression. They work fine.
:
: UPPER(Player[LoginID].Buffer[0]); //Wrong
: Player[LoginID].Buffer[0] = UPPER(Player[LoginID].Buffer[0]); //Right
: 

: I am currently writing descriptions and setting bonuses for races in the game and testing it out. So far it works flawlessly and generates no errors (except a single recv() error if you disconnect without telling the server you're leaving with a quit or exit command). You can go as far as selecting your race and seeing race descriptions right now. I plan on opening the server with five races and three classes to choose from. In the end, there can be an unlimited number of races and classes, but 5*3=15 possible routes, and if you do a multiclass character you can multiply 15 by 9 to get the total number of opening setups you can choose from. Now if only I found time to code the client...
:
: -Sephiroth
:
:
Write a macro to accept a pointer - you will call it once and with better performance (server code needs that!):
#define _2UPCASEBYREF(pChar)  \
  if (((pChar)[0] >= 'a') && ((pChar)[0] <= 'z')) { *pChar -= 0x20; }

#define _2LOCASEBYREF(pChar)  \
  if (((pChar)[0] >= 'A') && ((pChar)[0] <= 'Z')) { *pChar += 0x20; }




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.