Author Topic: Re: how to print string from array on screen from bottom to top?  (Read 528 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Hi @ron77

Saw this at that other place! ;-)) translated it for QB64.

Code: QB64: [Select]
  1. ' save this file as test.bas
  2.  
  3. 'ref: https://www.freebasic.net/forum/viewtopic.php?f=2&t=28589#p272611
  4. REDIM lines(0) AS STRING
  5. readfile "test.bas", lines()
  6. upper lines()
  7.  
  8. 'append to the string array the string item
  9. SUB sAppend (arr() AS STRING, item AS STRING)
  10.     REDIM _PRESERVE arr(LBOUND(arr) TO UBOUND(arr) + 1)
  11.     arr(UBOUND(arr)) = item
  12.  
  13. SUB readfile (f AS STRING, lines() AS STRING)
  14.     DIM fline AS STRING
  15.     OPEN f FOR INPUT AS #1
  16.     WHILE NOT EOF(1)
  17.         LINE INPUT #1, fline
  18.         sAppend lines(), fline
  19.     WEND
  20.     CLOSE #1
  21.  
  22. SUB upper (lines() AS STRING)
  23.     'dim as integer h = hiword(width()) 'num columns on display
  24.     'print closing credits
  25.     FOR i = 0 TO UBOUND(lines)
  26.         LOCATE 24, 1
  27.         PRINT lines(i)
  28.         _LIMIT 1
  29.     NEXT
  30.     'clear screen
  31.     FOR i = 1 TO 25
  32.         PRINT
  33.         _LIMIT 1
  34.     NEXT
  35.  
  36.  
  37.  

This sol'n seems kind of jerky to me.
« Last Edit: July 14, 2020, 03:06:00 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: how to print string from array on screen from bottom to top?
« Reply #1 on: July 14, 2020, 03:30:43 pm »
Better!
Code: QB64: [Select]
  1. ' save this file as test.bas
  2.  
  3. 'ref: https://www.freebasic.net/forum/viewtopic.php?f=2&t=28589#p272611
  4.  
  5. SCREEN _NEWIMAGE(640, 400, 32)
  6. REDIM lines(0) AS STRING
  7. readfile "test.bas", lines()
  8. upper lines()
  9. _PRINTSTRING (252, 184), "That's all folks."
  10.  
  11. 'append to the string array the string item
  12. SUB sAppend (arr() AS STRING, item AS STRING)
  13.     REDIM _PRESERVE arr(LBOUND(arr) TO UBOUND(arr) + 1)
  14.     arr(UBOUND(arr)) = item
  15.  
  16. SUB readfile (f AS STRING, lines() AS STRING)
  17.     DIM fline AS STRING
  18.     OPEN f FOR INPUT AS #1
  19.     WHILE NOT EOF(1)
  20.         LINE INPUT #1, fline
  21.         sAppend lines(), fline
  22.     WEND
  23.     CLOSE #1
  24.  
  25. SUB upper (lines() AS STRING)
  26.     'dim as integer h = hiword(width()) 'num columns on display
  27.     'print closing credits
  28.     FOR y = 405 TO -16 * UBOUND(lines) STEP -1
  29.         CLS
  30.         FOR i = 0 TO UBOUND(lines)
  31.             _PRINTSTRING (10, y + i * 16), lines(i)
  32.         NEXT
  33.         _PRINTSTRING (600, 10), STR$(y)
  34.         _DISPLAY
  35.         _LIMIT 60
  36.     NEXT
  37.  
  38.  
  39.  

_PRINTSTRING is such a relief from errors when trying to print off screen (compared to LOCATE & PRINT BUT! who wants to go over graphics and SCREENs with really green newbie?)
« Last Edit: July 14, 2020, 03:47:00 pm by bplus »

FellippeHeitor

  • Guest
Re: how to print string from array on screen from bottom to top?
« Reply #2 on: July 14, 2020, 04:48:19 pm »
My take on it:

Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3. CONST true = -1, false = 0
  4. CONST w = 800, h = 600
  5.  
  6. SCREEN _NEWIMAGE(w, h, 32)
  7.  
  8. RESTORE credits
  9. READ lineCount
  10. DIM text$(1 TO lineCount)
  11. FOR i = 1 TO lineCount
  12.     READ text$(i)
  13.  
  14. DIM y AS SINGLE, speed AS SINGLE
  15. y = h
  16. speed = .5
  17. centered = true
  18.     CLS
  19.  
  20.     y = y - speed
  21.     i = INT(y)
  22.     FOR t = 1 TO lineCount
  23.         IF centered THEN
  24.             leftside = (w - _PRINTWIDTH(text$(t))) / 2
  25.         ELSE
  26.             leftside = 150
  27.         END IF
  28.  
  29.         IF i >= -_FONTHEIGHT AND i <= h THEN
  30.             _PRINTSTRING (leftside, i), text$(t)
  31.         END IF
  32.         i = i + _FONTHEIGHT
  33.         IF i >= h THEN EXIT FOR
  34.     NEXT
  35.  
  36.     _DISPLAY
  37.     _LIMIT 60
  38.  
  39. credits:
  40. DATA 188
  41. DATA "DIRECTED,"
  42. DATA "PRODUCED & EDITED BY"
  43. DATA "Jonathan Goodman Levitt"
  44. DATA ""
  45. DATA "CO-EDITOR"
  46. DATA "& STORY CONSULTANT"
  47. DATA "Carla Ruff"
  48. DATA ""
  49. DATA "MUSIC BY"
  50. DATA "David Schweitzer"
  51. DATA "Zack Martin"
  52. DATA ""
  53. DATA "STARRING"
  54. DATA "David Beauregard, Jr."
  55. DATA "Nicholas Troiano"
  56. DATA "Benjamin Trump"
  57. DATA ""
  58. DATA "FEATURING"
  59. DATA "(IN ORDER OF APPEARANCE)"
  60. DATA "Senator Ted Kennedy"
  61. DATA "Louis & Denise Troiano"
  62. DATA "Diane Beauregard"
  63. DATA "Kathryn Braisted"
  64. DATA "Kevin Gallagher"
  65. DATA "Vicky Trump"
  66. DATA "David Beauregard, Sr."
  67. DATA "Governor Deval Patrick"
  68. DATA "Governor Mike Dukakis (MA Boys State, 1950)"
  69. DATA "State Senator Ken Cuccinelli"
  70. DATA "Professor Alison Thomas"
  71. DATA "Doug Bailey"
  72. DATA "Congresswoman Niki Tsongas"
  73. DATA "Professor Jay Aronson"
  74. DATA "Mayor Mike Bloomberg"
  75. DATA "Senator Chris Dodd"
  76. DATA "Senator Hillary Clinton"
  77. DATA "Senator Sam Brownback (KS Boys State, 1973)"
  78. DATA "Pastor Anthony Milas"
  79. DATA "President Bill Clinton (AK Boys State, 1963)"
  80. DATA "Chris Golden"
  81. DATA ""
  82. DATA "FILMED & RECORDED BY"
  83. DATA "Jonathan Goodman Levitt"
  84. DATA ""
  85. DATA "GRAPHICS"
  86. DATA "Producer: Emily Branham"
  87. DATA "Facilities Provided By: Edgeworx Studios & The Mill"
  88. DATA ""
  89. DATA "Design & Animation: Dave Tecson, Cassidy Gearhart & Emily Branham"
  90. DATA ""
  91. DATA "SOUND MIXING"
  92. DATA "De Lane Lea, Sound & Vision, London"
  93. DATA "Head of Production: Michael Hamilton"
  94. DATA "Dubbing Mixer: Adam Severs"
  95. DATA "Dubbing Fixer: Tony Curran"
  96. DATA ""
  97. DATA "Re-recording Mixer, New York:"
  98. DATA "Rob Daly"
  99. DATA ""
  100. DATA "CONSULTING EDITORS"
  101. DATA "Adam Zucker"
  102. DATA "Pagan Harleman"
  103. DATA "Nancy Kennedy"
  104. DATA ""
  105. DATA "ASSOCIATE EDITOR"
  106. DATA "Emiliano Battista"
  107. DATA ""
  108. DATA "COLOR CORRECTION"
  109. DATA "Pedro Padilla"
  110. DATA ""
  111. DATA "SOUND EDITING BY"
  112. DATA "Barbara Parks & Alex Noyes, Splash Studios"
  113. DATA "Rob Daly"
  114. DATA ""
  115. DATA "ADDITIONAL CINEMATOGRAPHY"
  116. DATA "Alex Stikich"
  117. DATA ""
  118. DATA "Additional Cameras, Election Day Shoot:"
  119. DATA "Slawomir Grunberg"
  120. DATA "Nadia Hallgren"
  121. DATA ""
  122. DATA "Research Shoot: James Rogan"
  123. DATA ""
  124. DATA "Additional Production Stills:"
  125. DATA "Jean-Christophe Vincent Couet"
  126. DATA ""
  127. DATA "ADDITIONAL GRAPHICS"
  128. DATA "Gap Sangpattharamatee, Mi-Sook Cho & Tim Van Horn"
  129. DATA ""
  130. DATA "Retouching:"
  131. DATA "Akwasi Poku & Randall Krueger"
  132. DATA ""
  133. DATA "Additional Color Correction:"
  134. DATA "Sam Wolfson, Edgeworx Studios"
  135. DATA ""
  136. DATA "Logo Design: Eugene Kolb"
  137. DATA ""
  138. DATA "ADDITIONAL SCORE"
  139. DATA "Tim Goalen"
  140. DATA "Erik Janson"
  141. DATA ""
  142. DATA "MUSIC CONSULTANTS"
  143. DATA "Jonathan Zalben"
  144. DATA "Derek Syverud"
  145. DATA ""
  146. DATA "ADDITIONAL MUSIC EDITING"
  147. DATA "Derek Syverud"
  148. DATA ""
  149. DATA "FEATURED SONG"
  150. DATA "'Don't Say Oh Well'"
  151. DATA "Written by Christian Zucconi,"
  152. DATA "Ryan Rabin, Hannah Hooper & Sean Gadd"
  153. DATA "Performed by Grouplove"
  154. DATA "Courtesy of Grouplove LLC"
  155. DATA ""
  156. DATA "LEGAL SERVICES"
  157. DATA "Shatzkin & Mayer, P.C."
  158. DATA "Karen Shatzkin & Debra Mayer"
  159. DATA ""
  160. DATA "Frankfurt Kurnit Klein & Selz, P.C."
  161. DATA "Tara Pietri & Victoria Cook"
  162. DATA ""
  163. DATA "PRODUCTION ASSISTANCE"
  164. DATA "Janet Goodman (US)"
  165. DATA "Anna Maconochie (UK)"
  166. DATA "Julie Sharon (NL)"
  167. DATA ""
  168. DATA "TRANSCRIPTIONS"
  169. DATA "Charlie Gershman"
  170. DATA "Amy Kessler"
  171. DATA "Cory Ness"
  172. DATA ""
  173. DATA "TRANSCRIPTIONS &"
  174. DATA "ADDITIONAL RESEARCH"
  175. DATA "Rob Hatch-Miller"
  176. DATA ""
  177. DATA "ARCHIVE COURTESY OF"
  178. DATA "MCTV: Karen Hayden"
  179. DATA "U.S. Army Central: Media Relations Group, Brittani White"
  180. DATA "Reagan Presidential Library: Steve Branch"
  181. DATA "Center for Defense Information: Mark Sugg"
  182. DATA "Great Projects Film Co., Inc.: Kenneth Mandel"
  183. DATA "Broadcast DelVal et al: Ryan Balton"
  184. DATA "Politics Now: Nick Troiano, Graham Vyse, Kristen Cleveland, Jason Cunningham, Chris Golden & Bharat Krishnan"
  185. DATA ""
  186. DATA "STILL PHOTOGRAPHS"
  187. DATA "COURTESY OF"
  188. DATA "Ben Trump & Family"
  189. DATA "D.J. Beauregard & Family"
  190. DATA "Graham Vyse"
  191. DATA "Nick Troiano & Family"
  192. DATA ""
  193. DATA "HOUSING PROVIDED BY"
  194. DATA "Arjen de Vries & Cathelijn Timmers"
  195. DATA "Carol Martin-Sperry & Michael Maconochie"
  196. DATA "Dori & Jeb Sophia"
  197. DATA "Fran Andreae"
  198. DATA "Janet Goodman"
  199. DATA "Judy & Rich Lapping"
  200. DATA "Katharine Szamuely"
  201. DATA "Louie Stowell & Karen Lawler"
  202. DATA "Minou Norouzi"
  203. DATA "Patrick Hazard"
  204. DATA ""
  205. DATA "DEVELOPED IN THE"
  206. DATA "Discovery Campus Masterschool, 2007"
  207. DATA ""
  208. DATA "PRODUCED IN ASSOCIATION WITH"
  209. DATA "Channel Four Television, UK"
  210. DATA ""
  211. DATA "SVT"
  212. DATA "Sveriges Television, Sweden"
  213. DATA "Commissioning Editor Axel Arnö"
  214. DATA ""
  215. DATA "NRK"
  216. DATA "Norsk Rikskringkasting, Norway"
  217. DATA "Commissioning Editor Tore Tomter"
  218. DATA ""
  219. DATA "DR"
  220. DATA "Danmarks Radio, Denmark"
  221. DATA "Commissioning Editor Mette Hoffman Meyer"
  222. DATA ""
  223. DATA "DISTRIBUTED BY"
  224. DATA "Kim Christiansen, DR International Sales"
  225. DATA ""
  226. DATA "FOR MY MOM"
  227. DATA "and other teachers"
  228. DATA "who lead by example"
« Last Edit: July 14, 2020, 04:53:35 pm by FellippeHeitor »

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: how to print string from array on screen from bottom to top?
« Reply #3 on: July 14, 2020, 07:31:11 pm »
My take on it:

That made me hum Star Wars music while I watched it.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: how to print string from array on screen from bottom to top?
« Reply #4 on: July 14, 2020, 11:46:46 pm »
I added a fading MOD to @FellippeHeitor Code
Code: QB64: [Select]
  1. 'By Fellippe
  2. 'Fading MOD by Ashish
  3. DEFLNG A-Z
  4.  
  5. CONST true = -1, false = 0
  6. CONST w = 800, h = 600
  7.  
  8. SCREEN _NEWIMAGE(w, h, 32)
  9.  
  10. RESTORE credits
  11. READ lineCount
  12. DIM text$(1 TO lineCount)
  13. FOR i = 1 TO lineCount
  14.     READ text$(i)
  15.  
  16. DIM y AS SINGLE, speed AS SINGLE
  17. DIM img&
  18. img& = _NEWIMAGE(w, h, 32)
  19. _DEST img&
  20. FOR i = 0 TO 128
  21.     LINE (x, i)-(w, i), _RGBA(0, 0, 0, 255 - (i * 2))
  22.     LINE (x, h - i)-(w, h - i), _RGBA(0, 0, 0, 255 - (i * 2))
  23. y = h
  24. speed = .5
  25. centered = true
  26.     CLS
  27.  
  28.     y = y - speed
  29.     i = INT(y)
  30.     FOR t = 1 TO lineCount
  31.         IF centered THEN
  32.             leftside = (w - _PRINTWIDTH(text$(t))) / 2
  33.         ELSE
  34.             leftside = 150
  35.         END IF
  36.  
  37.         IF i >= -_FONTHEIGHT AND i <= h THEN
  38.             _PRINTSTRING (leftside, i), text$(t)
  39.         END IF
  40.         i = i + _FONTHEIGHT
  41.         IF i >= h THEN EXIT FOR
  42.     NEXT
  43.     _PUTIMAGE , img&
  44.     _DISPLAY
  45.     _LIMIT 60
  46.  
  47. credits:
  48. DATA 188
  49. DATA "DIRECTED,"
  50. DATA "PRODUCED & EDITED BY"
  51. DATA "Jonathan Goodman Levitt"
  52. DATA ""
  53. DATA "CO-EDITOR"
  54. DATA "& STORY CONSULTANT"
  55. DATA "Carla Ruff"
  56. DATA ""
  57. DATA "MUSIC BY"
  58. DATA "David Schweitzer"
  59. DATA "Zack Martin"
  60. DATA ""
  61. DATA "STARRING"
  62. DATA "David Beauregard, Jr."
  63. DATA "Nicholas Troiano"
  64. DATA "Benjamin Trump"
  65. DATA ""
  66. DATA "FEATURING"
  67. DATA "(IN ORDER OF APPEARANCE)"
  68. DATA "Senator Ted Kennedy"
  69. DATA "Louis & Denise Troiano"
  70. DATA "Diane Beauregard"
  71. DATA "Kathryn Braisted"
  72. DATA "Kevin Gallagher"
  73. DATA "Vicky Trump"
  74. DATA "David Beauregard, Sr."
  75. DATA "Governor Deval Patrick"
  76. DATA "Governor Mike Dukakis (MA Boys State, 1950)"
  77. DATA "State Senator Ken Cuccinelli"
  78. DATA "Professor Alison Thomas"
  79. DATA "Doug Bailey"
  80. DATA "Congresswoman Niki Tsongas"
  81. DATA "Professor Jay Aronson"
  82. DATA "Mayor Mike Bloomberg"
  83. DATA "Senator Chris Dodd"
  84. DATA "Senator Hillary Clinton"
  85. DATA "Senator Sam Brownback (KS Boys State, 1973)"
  86. DATA "Pastor Anthony Milas"
  87. DATA "President Bill Clinton (AK Boys State, 1963)"
  88. DATA "Chris Golden"
  89. DATA ""
  90. DATA "FILMED & RECORDED BY"
  91. DATA "Jonathan Goodman Levitt"
  92. DATA ""
  93. DATA "GRAPHICS"
  94. DATA "Producer: Emily Branham"
  95. DATA "Facilities Provided By: Edgeworx Studios & The Mill"
  96. DATA ""
  97. DATA "Design & Animation: Dave Tecson, Cassidy Gearhart & Emily Branham"
  98. DATA ""
  99. DATA "SOUND MIXING"
  100. DATA "De Lane Lea, Sound & Vision, London"
  101. DATA "Head of Production: Michael Hamilton"
  102. DATA "Dubbing Mixer: Adam Severs"
  103. DATA "Dubbing Fixer: Tony Curran"
  104. DATA ""
  105. DATA "Re-recording Mixer, New York:"
  106. DATA "Rob Daly"
  107. DATA ""
  108. DATA "CONSULTING EDITORS"
  109. DATA "Adam Zucker"
  110. DATA "Pagan Harleman"
  111. DATA "Nancy Kennedy"
  112. DATA ""
  113. DATA "ASSOCIATE EDITOR"
  114. DATA "Emiliano Battista"
  115. DATA ""
  116. DATA "COLOR CORRECTION"
  117. DATA "Pedro Padilla"
  118. DATA ""
  119. DATA "SOUND EDITING BY"
  120. DATA "Barbara Parks & Alex Noyes, Splash Studios"
  121. DATA "Rob Daly"
  122. DATA ""
  123. DATA "ADDITIONAL CINEMATOGRAPHY"
  124. DATA "Alex Stikich"
  125. DATA ""
  126. DATA "Additional Cameras, Election Day Shoot:"
  127. DATA "Slawomir Grunberg"
  128. DATA "Nadia Hallgren"
  129. DATA ""
  130. DATA "Research Shoot: James Rogan"
  131. DATA ""
  132. DATA "Additional Production Stills:"
  133. DATA "Jean-Christophe Vincent Couet"
  134. DATA ""
  135. DATA "ADDITIONAL GRAPHICS"
  136. DATA "Gap Sangpattharamatee, Mi-Sook Cho & Tim Van Horn"
  137. DATA ""
  138. DATA "Retouching:"
  139. DATA "Akwasi Poku & Randall Krueger"
  140. DATA ""
  141. DATA "Additional Color Correction:"
  142. DATA "Sam Wolfson, Edgeworx Studios"
  143. DATA ""
  144. DATA "Logo Design: Eugene Kolb"
  145. DATA ""
  146. DATA "ADDITIONAL SCORE"
  147. DATA "Tim Goalen"
  148. DATA "Erik Janson"
  149. DATA ""
  150. DATA "MUSIC CONSULTANTS"
  151. DATA "Jonathan Zalben"
  152. DATA "Derek Syverud"
  153. DATA ""
  154. DATA "ADDITIONAL MUSIC EDITING"
  155. DATA "Derek Syverud"
  156. DATA ""
  157. DATA "FEATURED SONG"
  158. DATA "'Don't Say Oh Well'"
  159. DATA "Written by Christian Zucconi,"
  160. DATA "Ryan Rabin, Hannah Hooper & Sean Gadd"
  161. DATA "Performed by Grouplove"
  162. DATA "Courtesy of Grouplove LLC"
  163. DATA ""
  164. DATA "LEGAL SERVICES"
  165. DATA "Shatzkin & Mayer, P.C."
  166. DATA "Karen Shatzkin & Debra Mayer"
  167. DATA ""
  168. DATA "Frankfurt Kurnit Klein & Selz, P.C."
  169. DATA "Tara Pietri & Victoria Cook"
  170. DATA ""
  171. DATA "PRODUCTION ASSISTANCE"
  172. DATA "Janet Goodman (US)"
  173. DATA "Anna Maconochie (UK)"
  174. DATA "Julie Sharon (NL)"
  175. DATA ""
  176. DATA "TRANSCRIPTIONS"
  177. DATA "Charlie Gershman"
  178. DATA "Amy Kessler"
  179. DATA "Cory Ness"
  180. DATA ""
  181. DATA "TRANSCRIPTIONS &"
  182. DATA "ADDITIONAL RESEARCH"
  183. DATA "Rob Hatch-Miller"
  184. DATA ""
  185. DATA "ARCHIVE COURTESY OF"
  186. DATA "MCTV: Karen Hayden"
  187. DATA "U.S. Army Central: Media Relations Group, Brittani White"
  188. DATA "Reagan Presidential Library: Steve Branch"
  189. DATA "Center for Defense Information: Mark Sugg"
  190. DATA "Great Projects Film Co., Inc.: Kenneth Mandel"
  191. DATA "Broadcast DelVal et al: Ryan Balton"
  192. DATA "Politics Now: Nick Troiano, Graham Vyse, Kristen Cleveland, Jason Cunningham, Chris Golden & Bharat Krishnan"
  193. DATA ""
  194. DATA "STILL PHOTOGRAPHS"
  195. DATA "COURTESY OF"
  196. DATA "Ben Trump & Family"
  197. DATA "D.J. Beauregard & Family"
  198. DATA "Graham Vyse"
  199. DATA "Nick Troiano & Family"
  200. DATA ""
  201. DATA "HOUSING PROVIDED BY"
  202. DATA "Arjen de Vries & Cathelijn Timmers"
  203. DATA "Carol Martin-Sperry & Michael Maconochie"
  204. DATA "Dori & Jeb Sophia"
  205. DATA "Fran Andreae"
  206. DATA "Janet Goodman"
  207. DATA "Judy & Rich Lapping"
  208. DATA "Katharine Szamuely"
  209. DATA "Louie Stowell & Karen Lawler"
  210. DATA "Minou Norouzi"
  211. DATA "Patrick Hazard"
  212. DATA ""
  213. DATA "DEVELOPED IN THE"
  214. DATA "Discovery Campus Masterschool, 2007"
  215. DATA ""
  216. DATA "PRODUCED IN ASSOCIATION WITH"
  217. DATA "Channel Four Television, UK"
  218. DATA ""
  219. DATA "SVT"
  220. DATA "Sveriges Television, Sweden"
  221. DATA "Commissioning Editor Axel Arnö"
  222. DATA ""
  223. DATA "NRK"
  224. DATA "Norsk Rikskringkasting, Norway"
  225. DATA "Commissioning Editor Tore Tomter"
  226. DATA ""
  227. DATA "DR"
  228. DATA "Danmarks Radio, Denmark"
  229. DATA "Commissioning Editor Mette Hoffman Meyer"
  230. DATA ""
  231. DATA "DISTRIBUTED BY"
  232. DATA "Kim Christiansen, DR International Sales"
  233. DATA ""
  234. DATA "FOR MY MOM"
  235. DATA "and other teachers"
  236. DATA "who lead by example"
  237.  
  238.  
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

FellippeHeitor

  • Guest
Re: how to print string from array on screen from bottom to top?
« Reply #5 on: July 15, 2020, 12:01:02 am »
Nice!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: how to print string from array on screen from bottom to top?
« Reply #6 on: July 15, 2020, 01:39:54 am »
Aren't you guys over complicating a very simple process, for a learner?  Isn't this more or less what Ron was asking about -- "i have an array of string i wish to print the the string line after line from the bottom of the screen to the top like an ending title of a movie..."

Code: QB64: [Select]
  1. DIM TextArray(100) AS STRING
  2. FOR I = 0 TO 100
  3.     TextArray(I) = "Hello World" + STR$(I) ' a string
  4.     TextArray(I) = TextArray(I) + SPACE$(_WIDTH - LEN(TextArray(I))) 'with enough spaces to fill the entire line
  5.     'so we're certain that we erase anything that was written previously on the line.
  6.  
  7. FOR I = 0 TO UBOUND(TextArray) + _HEIGHT
  8.     LOCATE _HEIGHT - 1, 1 'print on the bottom few lines will scroll the screen automatically
  9.     IF I <= 100 THEN PRINT TextArray(I) ELSE PRINT 'so print the array + enough blank lines to continue to scroll it off the screen.
  10.     _DELAY .2

There's more comments in the above than there is code, and it seems to fulfill the original post's criteria.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!