View Full Version : fill spaces + reset
christianssen
15-03-2010, 13:27
hello.
I have again three little and short questions:
a) How I can fill s with spaces ? (command doesn't exist for thinbasic)
s = SPACES(20000) ' fill s with 20000 spaces
b) how to center a string within the space of another string ?
"coolstuff***THINBASIC***coolstuff"
c) something like "reset" command for variable or array as single command isn't useful I am thinking but I am asking ;)
thanks, denis
Michael Clease
15-03-2010, 14:18
s = SPC$(200000)
m = "My String"
s= MID$(m,LEN(s-LEN(m/2)))
RESET myarray()
christianssen
15-03-2010, 14:28
hi michael, thanks.
1) only spc$(20000) doesn't work.
2) "reset" I've found in manual help after second installation of thinbasic, strange, I didn't see it first time at manual help. only combobox/listbox rest appeared first time. now I have four commands. all ok.
thanks, denis
Michael Clease
15-03-2010, 14:43
Sorry Denis
s = $SPC(20000)
Look in core equates.
christianssen
15-03-2010, 14:51
michael, thanks but little sorry again ;)
in your example something's missing also for
s= MID$(m,LEN(s-LEN(m/2)))
manual says: 'MyMIDString = Mid$ (MyOLDString, 4, 2)
' Empty GUI script created on 03-15-2010 13:23:55 by denis (ThinAIR)
Uses "console", "ui"
Dim s,m,k As String
Dim myarray() As String
s = $SPC(200000)
m = "My String"
s = Mid$(m,Len(s-Len(m/2)),1) '-- something like this ?
'MyMIDString = Mid$ (MyOLDString, 4, 2)
k = "AnyString expression" & Mid$("ABCD", 3, 1)
MsgBox 0, ": " & Mid$("ABCD", 3, 1)
WaitKey
bye, denis
Petr Schreiber
15-03-2010, 15:59
To center string,
you can use dedicated CSET$:
Uses "console"
Dim s As String
s = CSet$(" thinBasic ", 40 Using "*")
PrintL s
WaitKey
ErosOlmi
15-03-2010, 18:37
As you can see there are many different ways to get a result in thinBasic because it has a rich set of predefined function.
The big set of native functionalities is the result of user requests made during last years.
manual says: 'MyMIDString = Mid$ (MyOLDString, 4, 2)
Length parameters is optional in MID$ function (when you see square brackets is syntax it means optional)
Manual also says:
If Length is omitted, or there are fewer than length characters to the right of the Start character of StringExpression, all remaining characters of StringExpression, including the Start character, are returned
Ciao
Eros
christianssen
16-03-2010, 09:47
thanks all :)
yes I see. There are always a lot of ways to get the task!
' Empty GUI script created on 03-16-2010 08:34:17 by denis (ThinAIR)
Uses "console"
Dim s,m,k,t As String
Dim myarray() As String
s = $SPC(200000)
PrintL "my name is Julius Cesar"
PrintL
m = "My fantastique romulus string"
's = Mid$(m,Len(s-Len(m/2)),1) '--> what's missing ?
k = "type any string expression" & Mid$("my Name is Cesar", 12, 1)
MsgBox 0, "12th. letter is: " & Mid$("my Name is Cesar, Julius", 12, 1)
PrintL
t = CSet$(" thinBasic is for free! ", 40 Using "*")
PrintL t
PrintL
t = CSet$(" I loved Cleopatra for years ", 50 Using "~")
PrintL t
WaitKey
"Line 11": perhaps somebody can fix this for correction ? (michael?)
salve like romans said, bye, denis