Simple Mathematics Question.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Simple Mathematics Question.

Post by Googie85 » Tue Jul 17, 2018 7:38 am

Hi Guys!!

I have google searched and I am unable to find a solution to a simple maths question.

I am making an app (Android) that records how many arrow shots that are fired by a person at an archery shooting range. The question is, how (mathematically), could I determine how many arrows (on average) are shot by the person per minute? Any help would be gratefully received!

Many Thanks,

Googie.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simple Mathematics Question.

Post by richmond62 » Tue Jul 17, 2018 8:13 am

That should be very simple indeed, and the Maths is,
but the implementation is where things can get
awkward if you are relatively new to LiveCode.

ajperks
Posts: 103
Joined: Sat Sep 06, 2014 3:38 pm

Re: Simple Mathematics Question.

Post by ajperks » Tue Jul 17, 2018 8:29 am

tTIME is the total time in minutes that archer is shooting.
tArrows is the total number of arrows fired by archer.
tAVERAGE is the answer of average arrows per minute for archer

tAVERAGE = tARROWS divided by tTIME

Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Re: Simple Mathematics Question.

Post by Googie85 » Tue Jul 17, 2018 8:52 am

Here is my app that I am working on. Any ideas on how I could make the Arrows per minute, based on the total arrows fired?

Image

Many Thanks,

Google.

Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Re: Simple Mathematics Question.

Post by Googie85 » Tue Jul 17, 2018 9:01 am

Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simple Mathematics Question.

Post by richmond62 » Tue Jul 17, 2018 9:42 am

pseudoCode

put theNumberOfArrows/minutesElapsed into averageShotsPerMin

Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Re: Simple Mathematics Question.

Post by Googie85 » Tue Jul 17, 2018 11:13 am

Hi Guys!!

I have the following code that needs to run in the background of my app:

global timeminutes,timecount,StopVar
on shootcount
if StopVar = "1" then
break
end if

if timecount = "60" then
put "0" into timecount
add "1" to timeminutes
put timeminutes&" Minutes." into temp
put temp into field "TimeElapsedTotal"
shootcount
else
wait 1 second
add "1" to timecount
shootcount
end if
end shootcount

I cant run any code after this part of my app is called.


Many Thanks,

Googie.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9647
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Simple Mathematics Question.

Post by dunbarx » Tue Jul 17, 2018 3:56 pm

Hi.

A hoot.

On a new card make a button and two fields. In the button script:

Code: Select all

local tSeconds, tStartTime, totArrows

on mouseUp
   put the seconds into tStartTime
   put the seconds into tSeconds
   put 0 into totArrows
   put 0 into fld 1
   put "" into fld 2
   shootCount
end mouseUp

on shootCount tSeconds
   put the seconds into tSeconds
   
   if the optionKey is down then exit to top --escape
   
   if the commandKey is down then put totArrows / (tSeconds - tStartTime) *  60 into fld 2
   
   if the controlKey is down then
      add 1 to totArrows
      put totArrows into fld 1
      wait 30
   end if
   
   send "shootCount" && tSeconds to me in 1
end shootCount
This is wordy, but that is just because I threw it together. Click the button to start the timing. Press the controlKey for each shot. Field 1 will count the number of arrows. When you press the CommandKey, the results of the session will be calculated, in shots per minute.

This needs to be adapted to your output gadget, but I hope you see what I was doing.

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9647
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Simple Mathematics Question.

Post by dunbarx » Tue Jul 17, 2018 11:47 pm

Just a postScript...

Heh, heh.

You mentioned that this had to run "in the backGround".

You understand that once this handler is set in motion, it will work while any other app is in front. In the background.

This may mean that my use of those three "control" keys is not quite what you might want. You will have to decide what those other apps might require to determine whether the control keys are breaking the intent of the handler. Are you OK with using some other means if so?

All right, already, Lagi.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”