• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

ssub - extracting data from a String for comparison and use

Messages
542
Country
australia
In a fight plan I have some waypoints that have TGT contained in their ID .
The placement of the TGT in the ident is done on purpose .

If I use this script ,
Code:
%((A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp  0 ==)%!s!%
Then as I progress through the flight plan it it returns 1 if TGT is in the ID , otherwise it returns 0 .

I need to use it in a Visibility statement to cause an effect if it returns 1 and does not if it returns 0

I tried this ,
Code:
(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp  0 ==  1 ==
but it does not seem to work

How do I write it for the 1 condition ?

Cheers
Karol
 
- scmp - Example 2. Compare strings. If equal will return -1
With the '!' added it will return 1 so if{} can be used.

<Value>
(@c:NearestAirportCurrentIdent,string)
'EHAM'
scmp ! (>L:Var5, bool)
</Value>

- scmp - Example 2a. Compare strings. Test String for Airport
ICAO.

<Value>
0 (>L:TransitionLevel,enum) c
(@c:NearestAirportCurrentIdent,string) sp0
l0 'EHAM' scmp ! if{ 40 }
l0 'EGLL' scmp ! if{ 70 }
(>L:TransitionLevel,enum)
</Value>

Old examples from the net by Mr. Kruijer

(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !
This gives 1.

Edi
 
Last edited:
sstr (find substring) might also work, i.e.,

Code:
(A:GPS WP NEXT ID, string) 'TGT' sstr !
 
Seems to me that what you have works if GPS WP NEXT ID is a string and the first three characters are 'TGT'. Supposing GPS WP NEXT ID was 'TGTA5', then

This would be 'Visible':
Code:
<Visible>(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp 0 ==</Visible>


And this would not be 'Visible':
Code:
<Visible>(A:GPS WP NEXT ID, string) 0 3 ssub 'TGQ' scmp 0 ==</Visible>


Or, if GPS WP NEXT ID was 'TGSA5', then this would not be 'Visible':
Code:
<Visible>(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp 0 ==</Visible>


Bob
 
Thank you for the above , I am now getting 1 if TGT is in ID , otherwise 0 , which is what I want .

I now need to apply it to the following code in the update ,
Code:
        (L:TgtSource,enum) 1 == (@c:FlightPlanIsActiveWaypointLocked,Bool) 1 == (L:ZipSingleWpt,enum) 0 == and and
      if{
          (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;              
          if{
               (&gt;K:RELEASE_DROPPABLE_OBJECTS)
               0 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
               1 (&gt;L:BmbReleaseLight,enum)
               0 (&gt;L:TgtSource,enum)
               0 (&gt;L:RdrPUMarker,enum)
               0 (&gt;L:FltPlnWptMarker,enum)
               0 (&gt; L:MarkPosMarker,enum)

         (L:ChgWPt, number) (A:GPS FLIGHT PLAN WP COUNT, number) 0 - &lt; (L:SequentialMultiWpt,enum) 1 == and
            if{
                (A:GPS FLIGHT PLAN WP INDEX, number) ++ (&gt; L:ChgWPt, number)
                (L:ChgWPt, number) (&gt; C:fs9gps:directToActivateLeg)
                (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanWaypointIndex)
                (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanDirectToWaypoint)
                (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanActiveWaypoint) }
          (L:bbbbSource,enum) 0 == (L:SequentialMultiWpt,enum) 1 == and      
             if{ 1 (&gt;L:TgtSource,enum)                
                 1 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
                 1 (&gt;L:FltPlnWptMarker,enum)
                 (A:GPS WP NEXT LAT, degrees) (&gt;L:Target LAT, degrees)
                 (A:GPS WP NEXT LON, degrees) (&gt;L:Target LON, degrees)
                 (A:GPS WP PREV ALT Meters) 3.2808 * (&gt;sHt agl,feet, feet)
                 (L:Target LAT, degrees) (&gt;L:MarkPositionLatitude,degrees)
                 (L:Target LON, degrees) (&gt;L:MarkPositionLongitude,degrees)
                 (L:BearingTargetPos,degrees) (&gt;L:HEADINGsavedMarkPos, degrees) }
                 (A:Indicated Altitude, feet) (L:TgtElevFt, Feet) -  (&gt;L:S_HtProxy,feet)                
            }
        }
1. If
Code:
(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !
returns 1 , then everything above is as it should be .

however
2. If
it returns 0 (zero) , then ,
Code:
(@c:FlightPlanIsActiveWaypointLocked,Bool)
is reset to 0 (switched Off
and
Code:
(&gt;K:RELEASE_DROPPABLE_OBJECTS)
is deactivated

The idea being that this portion of the Update remain continuously active so that when it detects a Wpt containing TGT it drops abomb
but if the next Wpt does not have a TGT it switches off the Locked Wpt and does not deploy a bomb .

Basically it would be interrogating each and every Wpt and deciding which are to be bombed , if they have TGT they are bombed .

At the moment the above code runs continuously for the duration of the flight plan and bombs all Wpts as it gets to them.

Cheers
Karol
 
Somehow reminds me of Fran Kubelik -- "I can type up a storm but I can't spell". All curlies balanced? (No.) Proper syntax for variable assignments etc? (No.) Error logging turned on? (No.) Bomb all waypoints? (Yes.)
 
Last edited by a moderator:
The idea being that this portion of the Update remain continuously active so that when it detects a Wpt containing TGT it drops abomb
but if the next Wpt does not have a TGT it switches off the Locked Wpt and does not deploy a bomb .

Basically it would be interrogating each and every Wpt and deciding which are to be bombed , if they have TGT they are bombed .

At the moment the above code runs continuously for the duration of the flight plan and bombs all Wpts as it gets to them.

Cheers
Karol

Wasn't the film "Dark Star" all about this? lol
 
bombs all Wpts as it gets to them
Reminds me to some political leaders:censored:

Karol
where are you searching for TGT? I can't see it in the above code.
Some more code?
 
Hi Edi

I like that regards politicians .

It searches or interrogates each A:GPS WP NEXT ID as you progress through the Flt Pln , looking to see if it contains a TGT .

There are two sources with TGT in them .
1. I created a 'Mission Adaptive Flight Plan Editor' in my MFD , it's rather flexible , can create long Flt Plns from scratch or modify saved plans at any time ,
before take off or during flight , you can replace plans as often as you like , it also has the ability to inject TGT into a waypoints ID .

2. Bill , ex USAF B-52's has created a large number of freeware USAF training flight plans , as a part of the Bomb Nav System (BNS) instrument development
he has injected , TGT waypoints , Elevations and BGL scenery targets into them .

Two versions of the BNS instrument are now completed , there are several others that I am using to explore , develop and test new features and ideas ,
the above is the beginning of one of the ideas .
The object is to eventually refine it so that it remains automated , and senses TGT's only for bombing , so the entire Flt Pln might for example have
have 40 to 60 waypoints , but only about 3 to 5 might be genuine Targets containing the TGT .

My aim has always been to maximise the flexibility of the BNS in all regards , speed , height , sourcing targets , and importantly flight modes ,
be it Nav hold , Hdg hold on autopilot or manually , precision steering display guidance and ground impact precision were vital and have been attained .
While you might have a long Flt Pln , you can at any time deviate from it , by adding a branch to it , or prosecuting a DTO then reinstate and rejoin the
original plan at any point that you desire .

Cheers
Karol
PS;
The baseline BNS instrument is shown in screenshots here at pge 2 ,
https://www.fsdeveloper.com/forum/threads/k-variable-in-element-section-single-switching.441580/
 
Last edited:
Old examples from the net by Mr. Kruijer

Edi - it's great of you to remember and give credit. Roelof Kruijer - wasn't that from AVSIM Panel Design forum in 2006? Over a decade ago :) It's a shame that a few years back AVSIM lost a lot of the historic panel forum threads, IIRC.

Bob
 
Last edited:
Karol,
it is really interesting what you are doing. I like it!
Generally spoken i understand what you want.

I had to edit your code. My old eyes...

Code:
   (L:TgtSource,enum) 1 ==
   (@c:FlightPlanIsActiveWaypointLocked,Bool) 1 ==
   and
   (L:ZipSingleWpt,enum) 0 ==
   and
   if{
     (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;             
     if{
       (&gt;K:RELEASE_DROPPABLE_OBJECTS)
       0 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
       1 (&gt;L:BmbReleaseLight,enum)
       0 (&gt;L:TgtSource,enum)
       0 (&gt;L:RdrPUMarker,enum)
       0 (&gt;L:FltPlnWptMarker,enum)
       0 (&gt; L:MarkPosMarker,enum)

       (L:ChgWPt, number) (A:GPS FLIGHT PLAN WP COUNT, number) 0 - &lt;
       (L:SequentialMultiWpt,enum) 1 ==
       and
       if{
         (A:GPS FLIGHT PLAN WP INDEX, number) ++ (&gt; L:ChgWPt, number)
         (L:ChgWPt, number) (&gt; C:fs9gps:directToActivateLeg)
         (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanWaypointIndex)
         (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanDirectToWaypoint)
         (L:ChgWPt, number) (&gt; C:fs9gps:FlightPlanActiveWaypoint)
         }

       (L:bbbbSource,enum) 0 ==
       (L:SequentialMultiWpt,enum) 1 ==
       and
       if{
         1 (&gt;L:TgtSource,enum)               
         1 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
         1 (&gt;L:FltPlnWptMarker,enum)
         (A:GPS WP NEXT LAT, degrees) (&gt;L:Target LAT, degrees)
         (A:GPS WP NEXT LON, degrees) (&gt;L:Target LON, degrees)
         (A:GPS WP PREV ALT Meters) 3.2808 * (&gt;sHt agl,feet, feet)
         (L:Target LAT, degrees) (&gt;L:MarkPositionLatitude,degrees)
         (L:Target LON, degrees) (&gt;L:MarkPositionLongitude,degrees)
         (L:BearingTargetPos,degrees) (&gt;L:HEADINGsavedMarkPos, degrees)
         }
       (A:Indicated Altitude, feet) (L:TgtElevFt, Feet) -  (&gt;L:S_HtProxy,feet)               
       }
     }

I assume that " (L:TgtSource,enum) 1 == " says, the next WPT should be bombed?! TGT stands for TARGET?

But i'm missing a condition check like this

(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !
if{
1 (&gt;L:TgtSource,enum)
}

Of course i can't inerpret some variable like
(L:bbbbSource,enum) 0 ==
(L:SequentialMultiWpt,enum) 1 ==

Keep on coding;)
Edi
 
Yes Bob,
the good old times..
Luckily i saved some important code and infos on my HD!!

Edi,

I saved info along the way too, but I'm sure not as thoroughly as you. I have always hoped that Bill Leaming squirreled away all the good 'acorns', but, alas, I recall Bill saying from time to time that various HDs of his bricked or got corrupted.:confused:
 
I've done what I can to rescue as many old posts as are available, but alas far too many went to the Great Bit Bucket In The Sky... :eek:
 
Hi Edi

Thank you for your patient understanding and help .

Also thanks for this ,
(A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !
if{
1 (&gt;L:TgtSource,enum)
}

I suspect that something along those lines might be the answer I'm searching for .

The L:TgtSource,enum covers the 4 different switches that "get" different Lat/Long formats for processing to a generic format .
The (L:bbbbSource,enum) 0 == is similar I didn't know how to handle the switches , so I used a silly idea , it works .
The (L:SequentialMultiWpt,enum) 1 == is purely experimental used to split one switch into two ,
Left click bomb single Wpts in Flt Pln
Right click Bomb Sequential multi Wpts in Flt Pln

The Update code gives a bit of an insight into the nuts and bolts of the BNS .
Following Update is from one of the simple completed versions ,
Code:
     <Update Hidden="Yes">       
        <Frequency>18</Frequency>
    (L:TgtSource,enum) 1 ==
              if{   
                 (A:GPS WP NEXT LAT, degrees) (&gt;L:Target LAT, degrees)
                 (A:GPS WP NEXT LON, degrees) (&gt;L:Target LON, degrees) }
    (L:TgtSource,enum) 2 ==
              if{   
                 (L:KoalaLatitude, degrees) (&gt;L:Target LAT, degrees)
                 (L:KoalaLongitude, degrees) (&gt;L:Target LON, degrees) }
    (L:TgtSource,enum) 3 ==
              if{   
                 (L:RequiredWaypointLatitude, degrees) (&gt;L:Target LAT, degrees)
                 (L:RequiredWaypointLongitude, degrees) (&gt;L:Target LON, degrees) }
    (L:TgtSource,enum) 4 ==
              if{   
                 (L:MarkPositionLatitude,degrees) (&gt;L:Target LAT, degrees)
                 (L:MarkPositionLongitude,degrees) (&gt;L:Target LON, degrees) }
                
            (L:Height Source,enum) 0 == 
              if{           
                  (A:RADIO HEIGHT, feet) (&gt;L:Height Basis, feet) }
            (L:Height Source,enum) 1 ==
              if{ 
                  (L:S_HtProxy,feet) (&gt;L:sHt agl,feet)
                  (L:sHt agl,feet) (&gt;L:Height Basis, feet) }
                  
    (L:BombTgtSW_ON,enum) 0 ==
         if{   
               100 350 (L:Height Basis, feet) rng  if{ 0.87228865 (&gt;L:TimeCorrectionFactor,number) }
               351 750 (L:Height Basis, feet) rng  if{ 0.846802653 (&gt;L:TimeCorrectionFactor,number) }                 
               751 1500 (L:Height Basis, feet) rng  if{ 0.75403803 (&gt;L:TimeCorrectionFactor,number) }               
               1501 2500 (L:Height Basis, feet) rng  if{ 0.64728021 (&gt;L:TimeCorrectionFactor,number) }               
               2501 3500 (L:Height Basis, feet) rng  if{ 0.569392963 (&gt;L:TimeCorrectionFactor,number) }
               3501 4500 (L:Height Basis, feet) rng  if{ 0.520858004 (&gt;L:TimeCorrectionFactor,number) }               
               4501 5500 (L:Height Basis, feet) rng  if{ 0.48223085 (&gt;L:TimeCorrectionFactor,number) }
               5501 6500 (L:Height Basis, feet) rng  if{ 0.465858004 (&gt;L:TimeCorrectionFactor,number) }
               6501 7500 (L:Height Basis, feet) rng  if{ 0.4172064762 (&gt;L:TimeCorrectionFactor,number) }
               7501 8500 (L:Height Basis, feet) rng  if{ 0.388289927 (&gt;L:TimeCorrectionFactor,number) }
               8501 9500 (L:Height Basis, feet) rng  if{ 0.371313601 (&gt;L:TimeCorrectionFactor,number) }
               9501 12500 (L:Height Basis, feet) rng  if{ 0.365074692 (&gt;L:TimeCorrectionFactor,number) }               
               12501 17500 (L:Height Basis, feet) rng  if{ 0.307367676 (&gt;L:TimeCorrectionFactor,number) }
               17501 22500 (L:Height Basis, feet) rng  if{ 0.289900265 (&gt;L:TimeCorrectionFactor,number) }               
               22501 27500 (L:Height Basis, feet) rng  if{ 0.270752584 (&gt;L:TimeCorrectionFactor,number) }               
               27501 32500 (L:Height Basis, feet) rng  if{ 0.240566766 (&gt;L:TimeCorrectionFactor,number) }
               32501 65500 (L:Height Basis, feet) rng  if{ 0.224515674 (&gt;L:TimeCorrectionFactor,number) }
              
               (A:GROUND VELOCITY, knots) 6076 * (&gt;L:DistPerKnot,feet)
               (L:DistPerKnot,feet) 3600 / (&gt;L:DistPerSecond,number)
               16.087 (&gt;L:HalfGvalue, number)
               (L:Height Basis, feet) (L:HalfGvalue, number) / sqrt (L:TimeCorrectionFactor,number) * (&gt;L:TimeToRun,number)
               (L:DistPerSecond,number) (L:TimeToRun,number) * (&gt;L:DistToRun,feet)

          (A:PLANE LATITUDE,degrees) (&gt;@c:GeoCalcLatitude1,degrees)
          (A:PLANE LONGITUDE,degrees) (&gt;@c:GeoCalcLongitude1,degrees)
          (L:Target LAT, degrees) (&gt;@c:GeoCalcLatitude2,degrees)
          (L:Target LON, degrees) (&gt;@c:GeoCalcLongitude2,degrees)
          (@c:GeoCalcBearing,degrees) (&gt;L:BearingTargetPos,degrees)
          (@c:GeoCalcDistance,nmiles) (&gt;L:DistanceTargetPos,nmiles)
        }       

    (L:TgtSource,enum) 1 == (@c:FlightPlanIsActiveWaypointLocked,Bool) 1 == and
      if{
          (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;               
          if{
               (&gt;K:RELEASE_DROPPABLE_OBJECTS)
               0 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
               1 (&gt;L:BmbReleaseLight,enum)
               0 (&gt;L:TgtSource,enum)           
            }
        }
        
    (L:TgtSource,enum) 2 == (L:GoBombTgt,enum) 1 == and
      if{
          (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;               
          if{
               (&gt;K:RELEASE_DROPPABLE_OBJECTS)
               0 (&gt;L:GoBombTgt,enum)
               1 (&gt;L:BmbReleaseLight,enum)
               0 (&gt;L:TgtSource,enum)
            }
         }         

    (L:TgtSource,enum) 3 == (L:GoBombTgt,enum) 1 == and
      if{
          (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;               
          if{
               (&gt;K:RELEASE_DROPPABLE_OBJECTS)
               0 (&gt;L:GoBombTgt,enum)
               1 (&gt;L:BmbReleaseLight,enum)
               0 (&gt;L:TgtSource,enum)
            }
         }

    (L:TgtSource,enum) 4 == (L:GoBombTgt,enum) 1 == and
      if{
          (L:DistanceTargetPos,feet) (L:DistToRun,feet) &lt;               
          if{
               (&gt;K:RELEASE_DROPPABLE_OBJECTS)
               0 (&gt;L:GoBombTgt,enum)
               1 (&gt;L:BmbReleaseLight,enum)
               0 (&gt;L:TgtSource,enum)
            }
         }

Cheers
Karol
 
Code is understandable.
But hard to help.
Code:
       (L:bbbbSource,enum) 0 ==
       (L:SequentialMultiWpt,enum) 1 ==
       and
       if{
         1 (&gt;L:TgtSource,enum)               
         1 (&gt;@c:FlightPlanIsActiveWaypointLocked,Bool)
         1 (&gt;L:FltPlnWptMarker,enum)
         (A:GPS WP NEXT LAT, degrees) (&gt;L:Target LAT, degrees)
         (A:GPS WP NEXT LON, degrees) (&gt;L:Target LON, degrees)
         (A:GPS WP PREV ALT Meters) 3.2808 * (&gt;sHt agl,feet, feet)
         (L:Target LAT, degrees) (&gt;L:MarkPositionLatitude,degrees)
         (L:Target LON, degrees) (&gt;L:MarkPositionLongitude,degrees)
         (L:BearingTargetPos,degrees) (&gt;L:HEADINGsavedMarkPos, degrees)
         }

Here the bomb run will be activated?
And the name of next WPT should include TGT?
(L:SequentialMultiWpt,enum) means several waypoints?
And tgtsource is 1 if flightplan is active?

But i get stuck with this.
For debug i would test (A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !

Code:
      (L:bbbbSource,enum) 0 ==
       (L:SequentialMultiWpt,enum) 1 ==
       and
      (A:GPS WP NEXT ID, string) 0 3 ssub 'TGT' scmp !
       and
      if{

Edi
 
Back
Top