Wednesday, December 19, 2007
strings
bcx basic manual home
STRINGS
right$(string$,number)
example
a$ = right$(a$,5) 'takes the five left most charecters
left$ 'this is the same concept as right$
mid$ 'this works the same as right$ only is the middle of the string
chr$
example
a$ = chr$(65) + chr$(66) 'adds the ascii char in the postion to end of the string
command$, argv$[a] (argv is dos c and not for windows) COMMAND$(i) (newer version for windows and console)
example
a$ = "The Command Line =" & Command$
********* example 2
i = 1
cmd$ = COMMAND$(i)
WHILE cmd$ <> ""
PRINT "Argument", i, " is [", cmd$, "]"
i++
cmd$ = COMMAND$(i)
WEND
Replace$
reverse$
example
Print Reverse$ ( "Hello There" )
FORMAT
Replace (main$ , match$ , change$)
examples
A$ = Replace$( "1234567890", "456", "-ABC-" )
REPLACE "Here" With "There" In a$
ucase$, lcase$ : upper case string, lower case string
example
v$ = ucase$(s$)
date$ : returns the date as a string
example
a$ = date$
time$ : returns the time as a string
example
a$ = time$
space$ : returns a number of spaces as a string
example
a$ = space$(6) : the number of spaces is in the parenthesis
repeat$
example
a$ = repeat$(10,"Hello ")
FindFirst$, FindNext$
example
A$ = FindFirst$("*.*")
A$ = FindNext$
curdir$,sysdir$, tempdir$ :current, system and temp directory
example
a$ = curdir$
instr$ : in string (is this in the string)
example
Sep = Instr(A$ , ",")
' if sep is > 0 then it is in the string otherwise it is not..
REMOVE$ 'removes a string from another string
example
REMOVE "abc" FROM Q$ ' Also legal in BCX-> Q$ = Remove$(Q$,"abc")
USING$
example
CLS
DIM A$
A$ = USING$ ("###,###,###.##" , -123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.###" , -123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.####" , 123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.#####" , 123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.#######" , 123456789.123456) : PRINT A$
A$ = USING$ (" ###,###,###.##" , 123456789.123456) : PRINT A$
A$ = USING$ (" $###,###,###.##" , 123456789.123456) : PRINT A$
STRINGS
right$(string$,number)
example
a$ = right$(a$,5) 'takes the five left most charecters
left$ 'this is the same concept as right$
mid$ 'this works the same as right$ only is the middle of the string
chr$
example
a$ = chr$(65) + chr$(66) 'adds the ascii char in the postion to end of the string
command$, argv$[a] (argv is dos c and not for windows) COMMAND$(i) (newer version for windows and console)
example
a$ = "The Command Line =" & Command$
********* example 2
i = 1
cmd$ = COMMAND$(i)
WHILE cmd$ <> ""
PRINT "Argument", i, " is [", cmd$, "]"
i++
cmd$ = COMMAND$(i)
WEND
Replace$
reverse$
example
Print Reverse$ ( "Hello There" )
FORMAT
Replace (main$ , match$ , change$)
examples
A$ = Replace$( "1234567890", "456", "-ABC-" )
REPLACE "Here" With "There" In a$
ucase$, lcase$ : upper case string, lower case string
example
v$ = ucase$(s$)
date$ : returns the date as a string
example
a$ = date$
time$ : returns the time as a string
example
a$ = time$
space$ : returns a number of spaces as a string
example
a$ = space$(6) : the number of spaces is in the parenthesis
repeat$
example
a$ = repeat$(10,"Hello ")
FindFirst$, FindNext$
example
A$ = FindFirst$("*.*")
A$ = FindNext$
curdir$,sysdir$, tempdir$ :current, system and temp directory
example
a$ = curdir$
instr$ : in string (is this in the string)
example
Sep = Instr(A$ , ",")
' if sep is > 0 then it is in the string otherwise it is not..
REMOVE$ 'removes a string from another string
example
REMOVE "abc" FROM Q$ ' Also legal in BCX-> Q$ = Remove$(Q$,"abc")
USING$
example
CLS
DIM A$
A$ = USING$ ("###,###,###.##" , -123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.###" , -123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.####" , 123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.#####" , 123456789.123456) : PRINT A$
A$ = USING$ ("$###,###,###.#######" , 123456789.123456) : PRINT A$
A$ = USING$ (" ###,###,###.##" , 123456789.123456) : PRINT A$
A$ = USING$ (" $###,###,###.##" , 123456789.123456) : PRINT A$