Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Weird findnig when playing with strings

Featured Replies

Hey all.I have been coding a transponder, and recently I asked for help on how to make it blink. Arne and Etienne answered me, and this is the current code:

FLOAT64 FSAPI	xpdr_code_cb (PELEMENT_STRING pelement){	FLOAT64 time=0;	BOOL is_masked=FALSE;	wsprintf(pelement->string,"%04x",pelement->source_var[0].var_value.d);	if(selected_digit>=0)	{		time=fmod(pelement->source_var[1].var_value.n,BLINK_FREQUENCY);	  //recalc to something between 0...1		time/=BLINK_FREQUENCY;		if(time>0.5)			is_masked=TRUE;		if(is_masked)			pelement->string[selected_digit]=' ';	}	return pelement->source_var[0].var_value.d;}//---------------------------------------------------------------------------BOOL	FSAPI	SetXpdr( PPIXPOINT relative_point, FLAGS32 mouse_flags){	if(mouse_flags&MOUSE_RIGHTSINGLE)	{		selected_digit++;		if(selected_digit==4)			selected_digit=-1;   }	   if(mouse_flags&MOUSE_LEFTSINGLE)	   {		   switch(selected_digit)		   {		   case   0:			   trigger_key_event(KEY_XPNDR_1000_INC,0);			   break;		   case   1:			   trigger_key_event(KEY_XPNDR_100_INC,0);			   break;		   case   2:			   trigger_key_event(KEY_XPNDR_10_INC,0);			   break;		   case   3:			   trigger_key_event(KEY_XPNDR_1_INC,0);			   break;	   }   }	   return   FALSE;}

Where

MAKE_STRING(	xpdr_code,	NULL,	xpdr_fail,	IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,	0,	68, 25,	90, 18,	4,	TRANSPONDER_CODE,	ELAPSED_SECONDS,	MODULE_VAR_NONE,	RGB (245,255,77),	RGB (0,0,0),	RGB (245,255,77),	GAUGE_FONT_ARIAL,	GAUGE_WEIGHT_DEFAULT,	GAUGE_CHARSET,	0,	DT_CENTER | DT_VCENTER | DT_SINGLELINE,	NULL,	xpdr_code_cb)PELEMENT_HEADER		xpdr_code_list[] ={	&xpdr_code.header,	NULL};

Arne, notice I took the +is_masked from the return of the xpdr_code_cb. I ran it with and without it, and it didn't make any difference.The objective of this was to be able to individually blink each number in the transponder code and adjust them. As of yet, this code does not make them blink. It erases them successfully, but they don't blink. The left mouse clicks work fine to increase them.But here is the weird part. When I first right click, to initiate this whole process, the runways, taxiways, and some building textures become dark. Not black, just a lot darker than what they were. Here is a pic of them normalhttp://miguez.virtualwideroe.com/tarmac1.jpgAnd here is one with the darker tarmac. Notice also the tower texture is darker. Also, the first transponder number is gone because I have selected it, so instead of blinking it is just maskedhttp://miguez.virtualwideroe.com/tarmac2.jpgHas anyone seen anything like this before? It never happened in my computer, and I changed resolutions and color depth from 16 to 32 several times, and was able to reproduce it every time, only when I clicked on the mouse rectangle that activates the above code.Once the code was complete, which means slected_digit was set back to -1, the problem disappeared.

When looking again at it:if(time>0.5) is_masked=TRUE; if(is_masked) pelement->string=' ';makes no real sense?? Why not just:if (time > 0.5) pelement->string = ' ';I doubt you need the is_masked at all.Also about the "return bla bla" I think it's completely unimportant what you return, you can e. g. just return FALSE or whatever as long as you wsprintf something.Etienne :-waveBTW Did ya render the background bitmap by yourself? It's awesome!

Hello Etienne.Good call on the loop. I don't see any difference between Arne's original and the proposed shorter one by you.But I am still unable to make them blink.Yes, the background is mine, it is for the upcoming Lancair Legacy by Bob C. Thanks for the compliments.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.