Qbasicnews.com
April 06, 2020, 11:47:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: string to array?  (Read 1938 times)
andy
Senior Member
**
Posts: 175



WWW
« on: January 02, 2004, 10:40:24 AM »

How can I convert a string such as a$ to an array, where each part of the array contains one letter of the string.

for example


a$ = "cat"
dim array(3)

...


print array(1) 'should print c
print array(2) 'should print a
print array(3) 'should print t

etc
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #1 on: January 02, 2004, 11:11:54 AM »

DIM, MID$() and LEN() and a FOR loop.

Here is the code:


len.a% = len(a$)
DIM array1$(1 TO len.a%)
FOR i% = 1 TO len.a%
array1$(i%) = MID$(a$, i%, 1)
NEXT i%
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
andy
Senior Member
**
Posts: 175



WWW
« Reply #2 on: January 02, 2004, 11:18:54 AM »

Thanks agamemnus, any particular reason for the mini font size?
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
ak00ma
Ancient Guru
****
Posts: 669



« Reply #3 on: January 02, 2004, 11:52:04 AM »

Maybe he wants you to write the code on your own...
Logged

B 4 EVER
andy
Senior Member
**
Posts: 175



WWW
« Reply #4 on: January 02, 2004, 06:22:37 PM »

I jst copied to word and increased the font size, but forgot to save the file so I wrote it myself anyway
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #5 on: January 03, 2004, 05:00:30 PM »

You can also copy to notepad... I always do that when printing news from a website that has annoying html gimmick stuff..
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
ak00ma
Ancient Guru
****
Posts: 669



« Reply #6 on: January 03, 2004, 05:29:23 PM »

Quote from: "Agamemnus"
You can also copy to notepad... I always do that when printing news from a website that has annoying html gimmick stuff..

 Jep..that's what I do..it's the best solution
Logged

B 4 EVER
Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #7 on: January 03, 2004, 06:49:09 PM »

or use mozilla. perfect size scaling Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!