TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: STEVE LEGG
date: 1995-09-11 15:02:00
subject: function declarations

Hi Everyone!
I need some help with a syntax thing.  I'm running PowerBASIC v3.0c, waiting
on my upgrade to 3.2, and having difficulty with declaring a couple of
functions that are part of a little program I've just built.
Here's the thing that doesn't seem to work for me.
'-------------------beginning of code snippet --------------------------
'=================================================================
' Program ....... M06FIX.BAS
' Author ........ STEVE LEGG
' Date .......... September 6, 1995
' Purpose ....... fix order of M06 instructions in CNC tape files
'
' Revisions -- 1.0 - initial release  September 6, 1995
'=================================================================
' declarations
DEFINT A-Z                     ' everything undeclared is an integer
DECLARE FUNCTION Trim$(BYVAL STRING) AS STRING
DECLARE FUNCTION GetNCWord(BYVAL STRING, BYVAL STRING) AS STRING
DIM FALSE AS INTEGER           ' the constant value for a Boolean FALSE
  FALSE = 0
DIM TRUE AS INTEGER            ' the value for a Boolean TRUE
  TRUE = -1
DIM InputFileName AS STRING    ' the filename we're going to work on
DIM OutputFileName AS STRING   ' the filename we'll write our results to
-- rest of the stuff deleted for brevity --
CLOSE                          ' close the files
END                            ' end the main program
FUNCTION Trim$(BYVAL StringContents AS STRING) LOCAL
'********************************************************************
'*  This function trims the spaces from both ends of a string       *
'********************************************************************
  Trim$ = LTRIM$(RTRIM$(StringContents))
END FUNCTION
FUNCTION GetNCWord(BYVAL NCBlock AS STRING, BYVAL Letter AS STRING) LOCAL
'********************************************************************
'*  This function returns the first NC word of the given letter     *
'*  address.  If there are no NC words with the given letter, it    *
'*  returns a NULL string                                           *
'********************************************************************
  DIM LetterPosn AS INTEGER    ' the place where we find the first letter
  DIM NCWord AS STRING         ' the word we're building
  DIM Char AS STRING           ' a character we read from the NCBlock
  LetterPosn = INSTR(NCBLock, Letter)
  IF LetterPosn > 0 THEN
    -- stuff deleted for brevity --
    GetNCWord = NCWord
  ELSE
    GetNCWord = ""
  END IF
END FUNCTION
'----------------------- end of code snippet ---------------------------
The program works fine, but I put the function declarations in because I
got brave and I turned on the full variable/array declaration requirement.
Although I understand the manual to say I can declare a function to return
a particular type this way, I get an error 527 (end of statement expected)
for each of the function declarations.  What have I done wrong?
Thanks for any help or pointers you can provide.  I'm still learning ...
and likely will be forever :).
-=        Steve Legg        -=-      RelayNet ->CRS     =-
-=  Oshawa, Ontario CANADA  -=-  steve.legg@canrem.com  =-
 * OLX 2.1 TD * Mouse drivers ** VERY small chauffeurs.
--- QScan/PCB v1.17b / 01-0348
---------------
* Origin: FidoNet: CRS Online, Toronto, Ontario (1:229/15)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.