A Question, Please

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Post Reply
Message
Author
The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

A Question, Please

#1 Post by The Artful Dodger »

Hello, All:
I have a programming question that I have been struggling with for a while and have not solved; I thought someone on the forum might have an answer:
I want to write a very short function that I can tack onto the end of a lib function to use the timer_start function to increment a variable, say AirSpeed by a value I set, but not 1. It works perfectly for 1 but nothing I try allows me to add, say 3.2 consecutively. Here's what I mean:

Code: Select all

function Setup(AS)
--
	ASCB(AS)
--
end
--
AS = 1
MyASTimer = timer_start(300, 300, Setup)
In the above, function ASCB(AS) is the CallBack function which processes the AS. I use this to "exercise" the instrument without having to fire up the sim!
Any (reasonable) suggestions would be most appreciated!

Sparky

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: A Question, Please

#2 Post by jph »

When you use the timer callback it passes only the count and the max number if set, the count will always be in steps of 1.

Code: Select all

function Setup(count) -- count is only in increments of 1 as it is purely the count of the times the timer has fired

	airspeed =  (count * increment )
	print (increment)
	print (airspeed)
	--ASCB(airspeed)
--
end
--
function ASCB(airspeed)
  
  -- do something
end

-- set some sample data
airspeed  = 1
increment = 3.2

-- set timer
MyASTimer = timer_start(300, 300, Setup)

-- be happy 
test this to see what is actually happening.

the 'fm' for timer start and the callback are here
https://siminnovations.com/wiki/index.p ... imer_start
Joe. CISSP, MSc.

The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

Re: A Question, Please

#3 Post by The Artful Dodger »

Hello:
It worked a treat. Thanks.

Sparky

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: A Question, Please

#4 Post by jph »

HTH
Joe ;)
Joe. CISSP, MSc.

Post Reply