BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›BRL

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Format

    • Introduction
    • TFormatter

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

BRL.Retro

The BASIC compatibility module provides miscellaneous functions that emulate the behaviour of 'classic' BASIC.

The functions in this module have largely been superceded by BlitzMax features such as 'string slicing', and the Find, Replace, Trim, ToLower and ToUpper string methods.

However, for programmers from a classic BASIC background, these utility functions should make the transition to BlitzMax a little easier.

NOTE: Strings in classic BASIC are '1 based'. This means that the first character within a string is at index 1, the second at index 2 and so on. However, BlitzMax strings are '0 based', meaning the first character is at index 0, the second at index 1 and so on. The instr and Mid functions in this module retain the '1 based' behaviour of classic BASIC.

Functions

Function Mid$( str$,pos,size=-1 )

Extract substring from a string

The Mid$ command returns a substring of a String.

Given an existing string, a position from the start of the string and an optional size, Mid creates a new string equal to the section specified. If no size if given, Mid returns the characters in the existing string from position to the end of the string.

For compatibility with classic BASIC, the pos parameter is 'one based'.

Returns

A sequence of characters from str starting at position pos and of length size

Example

SuperStrict

Local a:String = "abcd1234efgh"
Print Mid(a,5,5)   ' prints 1234e


Function Instr( str$,sub$,start=1 )

Find a string within a string

The start parameter allows you to specifying a starting index for the search.

For compatiblity with classic BASIC, the start parameter and returned position are both 'one based'.

Returns

The position within str of the first matching occurance of sub

Example

SuperStrict

Local mystring:String = "*sniffage*, I need more media!"

' check for the position
Print Instr(mystring,"more")

If Instr(mystring,"new PC") Print "large!"
If Not Instr(mystring,"new PC") Print "*sniff*"

If Instr(mystring,"media") Print "large!"


Function Left$( str$,n )

Extract characters from the beginning of a string

The Left$ command returns a substring of a String. Given an existing String and a size, Left$ returns the first size characters from the start of the String in a new String.

Returns

size leftmost characers of str

Example

SuperStrict

Print Left("12345678",4)   ' prints 1234


Function Right$( str$,n )

Extract characters from the end of a string

The Right$ command returns a substring of a String. Given an existing String and a size, Right$ returns the last size characters from the end of the String.

Returns

size rightmost characters of str

Example

SuperStrict

Print Right("12345678",4)   ' prints 5678


Function LSet$( str$,n )

Left justify string

Returns

A string of length n, padded with spaces

Example

SuperStrict

Print LSet("12345678",3)
Print "["+LSet("12345678",10)+"]"

' ==============
' Output
' 123
' [12345678  ]


Function RSet$( str$,n )

Right justify string

Returns

A string of length n, padded with spaces

Example

SuperStrict

Print RSet("12345678",3)
Print "["+RSet("12345678",10)+"]"

' ==============
' Output
' 678
' [  12345678]


Function Replace$( str$,sub$,replaceWith$ )

Performs a search and replace function

The Replace$ command replaces all instances of one string with another.

Returns

A string with all instances of sub$ replaced by replace$

Example

SuperStrict

Local str:String = "This is a test of the Replace command."
Print "Original: "+str

str = Replace(str,"e","*")

Print "Altered: "+str


Function Trim$( str$ )

Remove unprintable characters from ends a string

Returns

str with leading and trailing unprintable characters removed


Function Lower$( str$ )

Convert string to lowercase

Returns

Lowercase equivalent of str

Example

SuperStrict

Print Lower("abcdEFGH")     ' prints abcdefgh


Function Upper$( str$ )

Convert string to uppercase

Returns

Uppercase equivalent of str

Example

SuperStrict

Print Upper("Hello World") ' prints HELLO WORLD


Function Hex$( val )

Convert an integer value to a hexadecimal string

Returns

The hexadecimal string representation of val

Example

SuperStrict

For Local t:Int=0 To 255
    If Not(t Mod 16) Print
    Print "decimal: "+RSet(t,3)+" | hex: "+Hex(t)
Next


Function Bin$( val )

Convert an integer value to a binary string

Returns

The binary string representation of val

Example

' Prints the binary representation of a number

SuperStrict

Print Bin(1)
Print Bin(554)
Print Bin(1 | 554) ' OR in action


Function LongHex$( val:Long )

Convert a 64 bit long integer value to a hexadecimal string

Returns

The hexadecimal string representation of val


Function LongBin$( val:Long )

Convert a 64 bit long integer value to a binary string

Returns

The binary string representation of val


← TMethodBRL.Socket →
  • Functions
    • Function Mid$( str$,pos,size=-1 )
    • Function Instr( str$,sub$,start=1 )
    • Function Left$( str$,n )
    • Function Right$( str$,n )
    • Function LSet$( str$,n )
    • Function RSet$( str$,n )
    • Function Replace$( str$,sub$,replaceWith$ )
    • Function Trim$( str$ )
    • Function Lower$( str$ )
    • Function Upper$( str$ )
    • Function Hex$( val )
    • Function Bin$( val )
    • Function LongHex$( val:Long )
    • Function LongBin$( val:Long )
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson