|
REVERSE$ PowerBASIC Function |
|
REVERSE$ function evaluates to its parameter with the characters being placed in the reverse order. REVERSE$ serves as a functional interface for the simple FOR cycle, and its sole purpose is to support the functional style of programming, which I strongly prefer for all sorts of data conversion. REVERSE$ Source Program Debugging program Debugging logout |
' REVERSE$(0.0) Reverse Character String 03/17/1997-03/17/1997
' --------------------------------------------------------------------------
' Copyright (C) 1997 by Vladimir Veytsel www.davar.net
' Type ---------------------------------------------------------------------
' Function
' Declaration --------------------------------------------------------------
' DECLARE FUNCTION REVERSE$(Strng$)
' Parameter ----------------------------------------------------------------
' Strng$ - Character string to be reversed
' Value --------------------------------------------------------------------
' Character string of the same length as parameter string
' with characters in reverse order.
' Examples -----------------------------------------------------------------
' REVERSE$("") =""
' REVERSE$("A") ="A"
' REVERSE$("AB") ="BA"
' REVERSE$("ABC")="CBA"
' Start Function
FUNCTION REVERSE$(Strng$) PUBLIC
' Form and Return Function Value to the Point of Invocation ----------------
FOR I=LEN(Strng$) TO 1 STEP -1
Target$=Target$+MID$(Strng$,I,1)
NEXT I
REVERSE$=Target$
' Finish Function ----------------------------------------------------------
END FUNCTION
|
REVERSE$ Debugging Program Source program Debugging logout |
' REVERSE$(0.0) Reverse Character String 03/17/1997-04/04/2002
' --------------------------------------------------------------------------
$INCLUDE "REVERSE"
DECLARE FUNCTION REVERSE$(Strng$)
CLS
PRINT "REVERSE$(0.0) Reverse Character String ";DATE$;
PRINT " ";LEFT$(TIME$,5)
PRINT STRING$(58,"-")
PRINT
PRINT "REVERSE$('' )='"; _
REVERSE$("" ); "'"
PRINT "REVERSE$('A' )='"; _
REVERSE$("A" ); "'"
PRINT "REVERSE$('AB' )='"; _
REVERSE$("AB" ); "'"
PRINT "REVERSE$('ABC')='"; _
REVERSE$("ABC"); "'"
PRINT
PRINT "Execution completed - hit [Enter] to continue..."
|
REVERSE$ Debugging Logout Source program Debugging program |
REVERSE$(0.0) Reverse Character String 04-29-2003 18:05
----------------------------------------------------------
REVERSE$('' )=''
REVERSE$('A' )='A'
REVERSE$('AB' )='BA'
REVERSE$('ABC')='CBA'
Execution completed - hit [Enter] to continue...
|
|
View [and save] REVERSE.BAS text View [and save] ZREVERSE.BAS text (Use [Back] button or [Alt]+[CL] to return here from the viewed text) Copyright © 1997 by Go to: Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top |