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.

How do i show Morse Code as a string?

Featured Replies

Hi,I need some help displaying Morse Code for a VOR, you can already see it displayed on the world map, when you click on a VOR it shows up like ".. - .. .-" etc. I want to be able to display it on a panel, any help would be much appreciated.ThanksMatt

I've got the VOR1_IDENTITY to display and it would seem that FS converts the letters to morse rather than store the morse codes for each vor. Does any1 know an easy way i could either use FS to convert the letters and then display or just convert using C?Thanks Matt

Well, unless there is a variable with it in ASCII, then just parse it. Should be a bit of fun writing that loop. :)

This is what i use to print the string:lookup_var(&vor_id);sprintf(pelement->string,"%s",vor_id.var_value.p);how do i find out what each character is 1 by 1?thanksmatt

Actually, you may want to take a look at using the GPS variables (through XML in C) like: WaypointVorICAO ( the code you are seeking ) WaypointVorIdent ( the morse ) using: (C:fs9gps:Variable Name , Units)You do something like this: CHAR* VorIcaoCode; execute_calculator_code("(C:fs9gps:WaypointICAO, string)", VorIcaoCode, NULL, NULL);Do a search through the FS gps xml code to find the units used if 'string' doesn't work for you.Good luck.

Thanks for your help.With your code: FLOAT64 *VorIcaoCode; execute_calculator_code("(C:fs9gps:WaypointVorICAO,string)", VorIcaoCode, NULL, NULL); sprintf(pelement->string,"%s",VorIcaoCode);all i get is null, tried playing around with it but always get null.ThanksMatt

Matt,>Thanks for your help.No problem, many of us were where you are now. As long as you are trying, we enjoy helping.>With your code:>> FLOAT64 *VorIcaoCode;> >execute_calculator_code("(C:fs9gps:WaypointVorICAO,string)", VorIcaoCode, NULL, NULL);> sprintf(pelement->string,"%s",VorIcaoCode);>>all i get is null, tried playing around with it but always get>null.Matt, this is because you are doing several basic things wrong. The first step is you have to understand what you are doing.The parameter you need to pass in the execute_calculator_code function is a pointer (or address of) a variable to hold the result of the call.In your code, you pass "VorIcaoCode", which you did indeed declare to be of type FLOAT64* (pointer to FLOAT64), however, that pointer is not initialized to point at anything, and is therefore NULL, and so when the function attempts to see where to put the value it would like to "return" (store) for you, it finds that there is no where to put it. Normally, we would name that variable in Hungarian notation to be pVorIcaoCode to remind us it is a pointer, and not the variable itself. Moreover, you are wanting a zero terminate string back, not a FLOAT64.You need to declare the variable itself, and then pass the pointer to it like this for numeric returns:FLOAT64 isBaggageDoorOpen;FLOAT64 FSAPI BaggageDoor_cb(PELEMENT_ICON pelement){ execute_calculator_code("(A:EXIT OPEN:1, bool)", &isBaggageDoorOpen, NULL, NULL); bool isWarnBaggageDoor = isBaggageDoorOpen ? true : false;}In the above code, I passed the pointer in the 2nd parameter as I was passing the address of a FLOAT64. The & operator takes the address of the variable I have declared (set aside space for) and passes it (a pointer) to the function.If we look at the actual definition of the call in the gauge.h file we see: BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);And this tells us that if you want a PCSTRINGZ* (pointer to a zero terminated c-string) returned, you have to send the point in the last parameter.In summary, your code should be more like this: CHAR* VorIcaoCode; // Declaring a C-String (null terminated) execute_calculator_code("(C:fs9gps:WaypointVorICAO, string)", NULL, NULL, &VorIcaoCode); sprintf(pelement->string,"%s",VorIcaoCode);Good luck.

It no longer displays "(null)" but "0." instead, i've tried changing waypoints on the gps and also changing WaypointVorICAO for others such as WaypointAirportIdent etc but still displays "0.".Thanks Matt

Probably your printf.Post more of your code so we can help you.

  • Moderator

I've found you will get inconsistent results when looking for strings using execute_calculator_code(); unless you declare the desired variable as PCSTRINGZ. For example:char buf[100];PCSTRINGZ atc_flight_number; execute_calculator_code("(A:atc flight number,string)",NULL,NULL,&atc_flight_number); swprintf(buf,L"%S", atc_flight_number);In the case above, I would use this:PCSTRINGZ VorIcaoCode;execute_calculator_code("(C:fs9gps:WaypointICAO,string)",NULL,NULL,&VorIcaoCode);swprintf(buf,L"%S", VorIcaoCode);Of course, my swprintf routine is for use with GDI+... Another print routine is needed for non-GDI+ gauges. :)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Hers's what i've got so far:FLOAT64 FSAPI dom_Morse1_string_cb( PELEMENT_STRING pelement ){ PCSTRINGZ VorIcaoCode; execute_calculator_code("(C:fs9gps:WaypointVorICAO,string)", NULL, NULL, &VorIcaoCode); sprintf(pelement->string,"%s",VorIcaoCode); return 0;}MAKE_STRING( dom_Morse1_stdby_freq_string, NULL, NULL, IMAGE_USE_ERASE | IMAGE_USE_BRIGHT , 0, 55,145, 280,80, 6, VOR1_IDENTITY, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(255,128,0), RGB(0,0,0), RGB(92,92,92), GAUGE_dom_FONT_DEFAULT, GAUGE_dom_WEIGHT_DEFAULT, GAUGE_dom_Q, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, dom_Morse1_string_cb)PELEMENT_HEADER dom_Morse1_stdby_freq_string_list[] ={ &dom_Morse1_stdby_freq_string.header, NULL};MAKE_STATIC( dom_Morse1_background, BMP_BACKGROUND, &dom_Morse1_stdby_freq_string_list, NULL, IMAGE_USE_TRANSPARENCY, 0, 0,0)PELEMENT_HEADER dom_Morse1_background_list = &dom_Morse1_background.header;This still only prints "0." i've played around changing the printf but still no luck.I changed C:fs9gps:WaypointVorICAO to A:atc id and that worked.Thanks againMatt

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.