TGC Codebase Backup



Functions _Min(), _Max(), _Sub() by Peace

19th Jun 2005 2:23
Summary

Manipulate strings and values



Description

There are 2 functions to get the highest of 2 values _max() and the lowest value _min(), also a function to erase a given character out of a string _sub(). I need to used it to create own .ini files.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Remstart
   ------------------------------------------------------------------
   Author:        Volker Stepprath of Testaware
   Project:       Functions
   Version:       1.00
   Language:      DarkBASIC Professional v1.058
   Description:   Usefull functions to manipulate strings/values
   Date:          19. June 2005
   ------------------------------------------------------------------
Remend

print _Sub("T-H-I-S I-S A T-E-S-T","-") : `* Erase char "-" in string
print _Max(100,rnd(200))                : `* Get the highest value
print _Min(100,rnd(200))                : `* Get the lowest value

wait key

FUNCTION _Sub(a$,b$)
   a=len(a$)
   for i=1 to a
      if mid$(a$,i)<>b$ then c$=c$+mid$(a$,i)
   next i
ENDFUNCTION c$

FUNCTION _Max(a#,b#)
   if a#<b# then a#=b#
ENDFUNCTION a#

FUNCTION _Min(a#,b#)
   if a#>b# then a#=b#
ENDFUNCTION a#