Audrey, and yeah I vaguely remember something about Javascript for single parameter functions using the function with no parameter when called is possible. However, I definitely would not good coding style . . .
On Thu, Mar 3, 2016 at 12:15 AM, William Hermans <[email protected]> wrote: > *Yeah, I was thinking that the asynchronous/callback nature of javascript >> is the problem for this but I was wondering how to circumvent it.* >> > > The typical way to deal with this type of situation would be to write a > callback. In this case, it might be better to write a timed callback, > instead of running a constant loop. loops typically I tend to think of as > procedural, where javascript really isnt procedural in nature. More > callback / object oriented if that makes sense ? > > So perhaps use setTimeout() instead of a loop. > > On Wed, Mar 2, 2016 at 11:54 PM, Audrey <[email protected]> wrote: > >> I'm not sure why printStatus() doesn't require a argument when called, >> but that's what they used in the documentation ( >> http://beagleboard.org/support/BoneScript/analogRead/) and I have used >> it for a single data point and it worked. I believe analogRead passes in >> the argument x into printStatus for you. >> >> Yeah, I was thinking that the asynchronous/callback nature of javascript >> is the problem for this but I was wondering how to circumvent it. >> >> On Thursday, March 3, 2016 at 1:37:49 AM UTC-5, William Hermans wrote: >>> >>> var b = require('bonescript'); >>> while (true) { >>> analogRead('P9_36', printStatus); >>> } >>> function printStatus(x) { >>> console.log('x.value = ' + x.value); >>> } >>> >>> I havent seen the prototype for analogRead() but the above code seems >>> wrong. printStatus() takes a single arguement, yet you're not passing any >>> argument to it. Another thing I would like to point out. All Javascript >>> should be async in nature, since Javascript is callback oriented. This is >>> like one of the major language attractions over other languages. >>> >>> Anyway, I'm thinking your problem with not getting anything to print, is >>> that you're not actually passing anything to the printing function . .. >>> >>> On Wed, Mar 2, 2016 at 10:02 PM, Audrey <[email protected]> wrote: >>> >>>> Hi sorry, yeah no I did actually use >>>> >>>> b.analogRead('P9_36', printStatus); >>>> >>>> although I did write it here as just analogRead('P9_36', printStatus); >>>> >>>> So I don't think that's the issue, although good point. >>>> >>>> On Wednesday, March 2, 2016 at 11:07:41 PM UTC-5, Dennis Lee Bieber >>>> wrote: >>>>> >>>>> On Wed, 2 Mar 2016 15:06:05 -0800 (PST), Audrey >>>>> <[email protected]> declaimed the following: >>>>> >>>>> > >>>>> >Hi guys, >>>>> > >>>>> >So I want to use the function analogRead() with a while loop, like >>>>> so: >>>>> > >>>>> >var b = require('bonescript'); >>>>> >while (true) { >>>>> > analogRead('P9_36', printStatus); >>>>> >>>>> Based upon all the examples I've seen, you need to reference >>>>> the >>>>> analogRead() IN THE "require" MODULE... >>>>> >>>>> b.analogRead(...) >>>>> >>>>> http://beagleboard.org/Support/BoneScript/analogRead/ >>>>> -- >>>>> Wulfraed Dennis Lee Bieber AF6VN >>>>> [email protected] HTTP://wlfraed.home.netcom.com/ >>>>> >>>>> -- >>>> For more options, visit http://beagleboard.org/discuss >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "BeagleBoard" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to the Google Groups >> "BeagleBoard" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
