realbasic-nug
[Top] [All Lists]

Re: Function Help

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Function Help
From: Frank Bitterlich <bitterlich at gsco dot de>
Date: Tue, 31 Aug 2004 17:17:34 +0200
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <6DA4EC73-FB5F-11D8-836E-000A95CC8426 at lumigen dot com>
Jason,
maybe you should do the tutorials; they show how to return values from functions and similar.

In this example, the function should read...

Function CutOffWeight() as Single
   return CDbl(CutOffField.Text)
end Function

... and you should avoid having a property with the same name as a function.

Another tip: Unless you know that your serial device will _never_ send more or less than exactly 18 bytes, I would change this...
   if j=18 then

... to this...

   if j >= 18 then


Cheers,
   Frank+++


Am 31.08.2004 um 17:07 schrieb Jason Boes:

CutOffWeight is a TextArea. I am Trying to get the code to warn me if the Value returned by the scale is lower than the text entered in Field to warn me. I am just wondering what I am missing.


Protected Function CutOffWeight (a As Single) As Single
     a = Val(CuttOffField.Text)
End Function


Property ( CutOff Weight As Single)

In Serial Data Available:
  Dim j As Integer
  Dim k As Single

  j = Len(Serial1.LookAhead())

  If j = 18 then
    Beep
    k = Val(Right(Serial1.Read(18),14))
    TotalWeightText.Text = str(k)+ " g"
    if k < CutOffWeight() then
      beep
      beep
      beep
      beep
      beep
    End If
  End If

Jason Boes
IT/Instrumentation
Lumigen, Inc.
(248) 455-8282

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>



--

Günter Schmidt & Co. oHG
Frank Bitterlich             eMail: bitterlich at gsco dot de
Schlosserstr. 4              WWW:   http://www.gsco.de/
D-60322 Frankfurt            Tel.:  069 / 156809-29
GERMANY                      Fax:   069 / 156809-28

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>