Jump to content
Sign in to follow this  
n4gix

Newbie MAKE_STRING question

Recommended Posts

Guest Magma

That was it thanks Doug! Of course what shows up on the screen is "%3d" which I'm assuming I have to change the data type first in order to properly read the CLOCK_SECOND token variable.Thanks again.Magma

Share this post


Link to post
Share on other sites
Guest jimcooper1

FLOAT64 FSAPI update_callback(PELEMENT_STRING pelement ){ FLOAT64 val=pelement->source_var(0).var_value.n; //(use Square brackets though) wsprintf(pelement->string, "%3d",(UINT32)val); return val;}

Share this post


Link to post
Share on other sites
Guest Magma

Thanks I just tried what you suggested and it still just showed me "%3d". However I have been playing around with the "%3d" value and have almost got it working with L"%d" value. Using that value I see only the most significant value of the CLOCK_SECOND variable. I've tried L"%2d" and L"%3d" without any luck. Is there a good online tutorial of what the proper syntax would be for this. What does the "L" mean?Magma

Share this post


Link to post
Share on other sites
Guest jimcooper1

>Thanks I just tried what you suggested and it still just>showed me "%3d". However I have been playing around with the>"%3d" value and have almost got it working with L"%d" value.>Using that value I see only the most significant value of the>CLOCK_SECOND variable. I've tried L"%2d" and L"%3d" without>any luck. Is there a good online tutorial of what the proper>syntax would be for this. What does the "L" mean?>>MagmaThe code should work.. I pasted it into one of my gauges and it ran fine and displayed the CLOCK_SECONDS OK. I tried your code with the L"%d" and I received a compile warning. It then displayed nothing.Copy and paste the whole of your code in its entirety here or send me a PM/e-mail with it.regardsJim

Share this post


Link to post
Share on other sites
Guest Magma

It must have something to do with the compiler. I'm using MS Visual C++ 2005 Express Edition Ver 8.0. Here is all the .c code:#include "..incgauges.h"#include #include "BLD.h"#define GAUGE_NAME "B L D0"#define GAUGEHDR_VAR_NAME gaugehdr_BLD#define GAUGE_W 100#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMALextern PELEMENT_HEADER BLD_Small;STRING_UPDATE_CALLBACK update_callback;char BLD_gauge_name[] = GAUGE_NAME;GAUGE_HEADER_FS700(GAUGE_W, BLD_gauge_name, &BLD_Small, NULL, NULL, 0, 0, 0);MAKE_STRING(update_code,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_BRIGHT , 0,50, 50,40, 20,4,CLOCK_SECOND ,MODULE_VAR_NONE ,MODULE_VAR_NONE ,RGB(0,255,0),RGB(0,0,0), RGB(92,92,92),GAUGE_FONT_DEFAULT,GAUGE_WEIGHT_DEFAULT,GAUGE_CHARSET,0,DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL,update_callback)PELEMENT_HEADER update_code_list[] ={&update_code.header,NULL}; MAKE_STATIC(BLD_background,BMP_SMALL_BLD,&update_code_list,NULL,IMAGE_USE_TRANSPARENCY,0,0,0);PELEMENT_HEADER BLD_Small = &BLD_background.header;FLOAT64 FSAPI update_callback(PELEMENT_STRING pelement ){FLOAT64 val=pelement->source_var[0].var_value.n;wsprintf(pelement->string, L"%d",(UINT32)val);return val;}void FSAPI ModuleInit(void){}void FSAPI ModuleDeinit(void){}GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_BLD) GAUGE_TABLE_END()It compiles fine except one warning that says:bld.c(33) : warning C4133: 'function' : incompatible types - from 'PCHAR' to 'LPWSTR'Thanks for your help. When I get passed all this syntax crap it should be smooth sailing for me.Magma

Share this post


Link to post
Share on other sites
Guest jimcooper1

Magma,The only error I can see is the L"%d"Apart from that it looks fine?????????????????Regards Jim

Share this post


Link to post
Share on other sites
Guest Magma

??????? is right. I'm not sure why my compiler partially likes the "L" in front of "&d", and I don't even know what it means! I see others have used the "L" but I can't find any explanation for it online. I was about to go off on a rant about the guess work involved in programming in a Microsoft environment but I think I'll save my strength and pray that I randomly hit the right combination that this compiler wants.Magma

Share this post


Link to post
Share on other sites
Guest Magma

Also, I'm getting a warning when compiling which points toward the wsprintf line:wsprintf(pelement->string, L"%d", (UINT32)val);Output:warning C4133: 'function' : incompatible types - from 'PCHAR' to 'LPWSTR'Could there a problem with pelement->string?Magma

Share this post


Link to post
Share on other sites
Guest Magma

For those that interested and for the history of this string...I figured out my problem. You have to set your preprocessor definitions to ANSI. You do this in MS Visual C++ 2005 Express Edition by right clicking on your project then select Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions and type in ;ANSI at the end of the string. It's just common sense! (what a joke)Thomas

Share this post


Link to post
Share on other sites

Interesting... I don't have to do that...This is all that is in Preprocessor Definitions in my MSVC++ .NET 2003 IDE:WIN32;NDEBUG;_WINDOWS;_USRDLL


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...