MID$ Function (New Features)

by lrcvs, Sunday, September 30, 2012, 17:43 (1671 days ago)

#This program writes a text in a specific position on a string pattern.
#This is the MID$ "Statement" when acts like a statement in QBasic.

# Mid( string master, start ) = text
# Mid( string master, start, length of text) = text


#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

cls
#string master
a$ = "......................................................."

c = length (a$)

dim z$(c + 1 )

#write string master into array
for k = 1 to c
z$[k] = mid (a$,k,1)
next k

#reinit program
reinicio:
y$ = ""

#string test to write into array
input "Text to write: " , b$
input "Position 1... ", p

d = length (b$)
if p > c then p = c - d
cls

#write string into array
for j = 1 to d
z$[p+(j-1)] = mid (b$,j,1)
next j

#show string master
for n = 0 to c
y$ = y$ + z$[n]
next n
print y$

goto reinicio

MID$ Function

by nimeia ⌂, Thursday, October 04, 2012, 08:39 (1668 days ago) @ lrcvs

MID$ Function

by Jim ⌂ @, Russell, KY, Monday, October 08, 2012, 01:01 (1664 days ago) @ lrcvs

Here is a "replaceat" function using the new 0.9.9.x functionality of functions.

a$ = "this is a string"
print repaceat$(a$,6,2,"was")
end

function replaceat$(str$,start, len, new$)
replaceat$ = ""
if start>1 then replaceat$ = mid(str$,1,start-1)
replaceat$ = replaceat$ + new$
if len > 0 then replaceat$ = replaceat$ + mid(str$,start+len,99999)
end function

MID$ Function

by lrcvs, Monday, October 08, 2012, 05:39 (1664 days ago) @ Jim

Looks very interesting, thanks!

RSS Feed of thread
powered by my little forum