Glock
New Member
Posts: 13
|
Post by Glock on Jan 22, 2023 15:08:31 GMT -5
Hi all
I haven't programmed for years and am slowly working through Carl's Beginning Programming book.
How would I adjust my code to return the string where the words are printed vertically? Currently it prints each letter vertically.
I'm guessing it has something to do with values in the mid$() function?
string$ = "A vertical sentence"
for pointer = 1 to len(string$)
print mid$(string$, pointer, 1)
next pointer
end
Thank you
Rob
|
|
|
Post by Brandon Parker on Jan 22, 2023 16:43:56 GMT -5
Hello glock, Welcome to the LB Community! Does the code below do what you are asking? Otherwise, I am not certain I understand what you are asking...
string$ = "A vertical sentence"
for pointer = 1 to len(string$)
var$ = (var$ + chr$(13) + mid$(string$, pointer, 1))
next pointer
Print var$
end
{:0)
Brandon Parker
|
|
Glock
New Member
Posts: 13
|
Post by Glock on Jan 22, 2023 17:10:44 GMT -5
Hi Brandon
Thanks for that. What I was looking for was each word printed vertically. For example the result would be:
A Vertical Sentence
Thanks
Rob
|
|
|
Post by Brandon Parker on Jan 22, 2023 17:30:16 GMT -5
In that case, this is more in line with what you would want to do.
string$ = "A vertical sentence"
For pointer = 1 To len(string$)
Print Word$(string$, pointer, " ")
Next pointer End
{:0)
Brandon Parker
|
|
Glock
New Member
Posts: 13
|
Post by Glock on Jan 22, 2023 17:57:47 GMT -5
Great. Thanks Brandon.
|
|
|
Post by tsh73 on Jan 23, 2023 4:28:01 GMT -5
Another way
string$ = "A vertical sentence" for pointer = 1 to len(string$) print mid$(string$, pointer, 1); '(;) on end of print prefents new line if mid$(string$, pointer, 1) =" " then print 'then space, empty print adds new line next pointer
end
|
|
Glock
New Member
Posts: 13
|
Post by Glock on Jan 23, 2023 12:01:45 GMT -5
Thanks for your help.
|
|