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.

Endless Loop

Featured Replies

So here is my problem. An XML gauge with an equation with an end variable X that is dependent upon the previous state of the variable X, plus a constantly changing variable Y.The equation: X=X+Y Both X and Y are constantly being updated and the output is fed into the new X. All well and good. But the kicker is I need this updated as fast as possible (refresh at 18) but without getting into an endless loop. In other words, X=X+Y, if left untouched, becomes nothing more than an incremental counter as the gauge constantly says: (oldX)+Y = (new X) so the (new X) now equals the (old X), so it adds Y again and so on.What I need is a way in XML to look at the equation, see if anything has changed, increment/decrement only if changes are made and not to form an endless loop.If any of this makes any sense, I would love to see you guys solutions.Steve

This is only logic, you can work out the syntax...Z!=Y if { X=X+Y }(Other code here, ending with: )Z=Y********The idea being that the last thing you do in any iteration is save the value of Y as Z so that, when you go get the current value of Y in the next iteration, you still have the old value to compare it to.Then test to see if the value is the same as last time... if so, skip your IF code. If it has changed, then update X.If you're testing to see that Y is non-zero then that's even easier... you don't even have to use Z at all.Scott

Steve,I've been exhausted lately and just passed out for a few hours. I looked here again to check on a few topics and just now realized that this thread was started by *you*... So, I'll change gears here and look at this as if the answer couldn't possibly be as simple as I'd first thought.(Please excuse typos... I'm a big guy and usually use a Microsoft Natural keyboard that's huge and has a split in the middle but it failed to survive an encounter with Mt. Dew so I'm using a regular backup keyboard. This thing is TINY and I have trouble with the keys...)>So here is my problem. An XML gauge with an equation with an>end variable X that is dependent upon the previous state of>the variable X, plus a constantly changing variable Y.This says to me that old X always equals old X but Y changes.... therefore my first answer would work....>Both X and Y are constantly being updated and the output is>fed into the new X. This tells me that new X could be completely different from old X... meaning that this is possible:oldX = 5oldY = 1oldX+Y = 6newX = 326>What I need is a way in XML to look at the equation, see if>anything has changed, increment/decrement only if changes are>made and not to form an endless loop.Assuming that "anything" means that X could change as well as Y, we then need the following:************************************X != A if { A = X B = Y X = X + Y } els { Y != B if { A = X B = Y X = X + Y } }************************************It's a simple nested if approach that flows this way:1) Test to see if newX = oldX2) If not, update A and B to represent the current X and Y, then run the X + Y update and move on to other code.3) If newX = oldX, then test to see if newY = old Y4) If not, update A and B to represent the current X and Y, then run the X + Y update and move on to other code.5) If oldY = newY, skip to the rest of the code and leave everything as is.This still strikes me as something that you'd be helping me with, not the other way around. Am I misunderstanding what you need or have you been in the egg nog again buddy? (grin)Scott / Vorlin

Hey Scottyeah its me :-)Complete brain f@rt with this one, as I'm having logic difficulties. Must be getting too old. Will have a look at the code you provided and work through the logic. I appreciate the help.Steve

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.