|
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-02/09/2010
' ------------------------------------------------------------------------------
' Copyright (C) 1997-2010 by Vladimir Veytsel www.davar.net
' Type -------------------------------------------------------------------------
' Function
' Parameter --------------------------------------------------------------------
' Strng$ - Character string to be reversed
' Value ------------------------------------------------------------------------
' Character string of the same length as parameter string with characters
' in the reverse order.
' Examples ---------------------------------------------------------------------
' REVERSE$("") =""
' REVERSE$("A") ="A"
' REVERSE$("AB") ="BA"
' REVERSE$("ABC")="CBA"
' Start Function ---------------------------------------------------------------
DEFINT A-Z ' All defaulted variables are integer
FUNCTION REVERSE$(Strng$)
' 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-02/09/2010
' ------------------------------------------------------------------------------
#INCLUDE "REVERSE"
FUNCTION PBMAIN
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"); "'"
END FUNCTION
|
REVERSE$ Debugging Logout Source program Debugging program |
REVERSE$(0.0) Reverse Character String 09-17-2016 15:13
----------------------------------------------------------
REVERSE$('' )=''
REVERSE$('A' )='A'
REVERSE$('AB' )='BA'
REVERSE$('ABC')='CBA'
|
|
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–2010 by Go to: Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top |