Ways to read a string one character at a time

Just starting out? Need help? Post your questions and find answers here.
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Ways to read a string one character at a time

Post by Jarlve »

Hello,

I am trying to resolve a HTTPRequest issue.

For that I wonder if there are other ways to read a string one character at a time besides using Mid:

Code: Select all

string$="SpiderBasic1 2 3"

For i=1 To Len(String$)
  Debug Mid(String$,i,1)
Next i
Thanks.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Ways to read a string one character at a time

Post by Peter »

Hello Jarlve,

MID() is actually the preferred way to get single letters within a string. Can you briefly explain why you are asking about it? Because I suspect that what you have in mind can possibly be solved in other ways.

Greetings ... Peter
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Re: Ways to read a string one character at a time

Post by Jarlve »

Hey Peter,

My program needs to load and read a self structured ASCII/UTF8 file which has multiple lines. I do not understand what HTTPRequest does. I think it joins the lines together while adding a space between the strings of each line.

Furthermore it may seem that Mid is behaving strangely with very large strings (30 MB) but it may also be my misunderstanding of HTTPRequest.

1) I need to know exactly what HTTPRequest does.

2) String$=ReadString(0) or String$+ReadString(0) on a 30 MB file consumes almost 2 GB of memory in the task manager.

Thanks.

Jarl
poshu
Posts: 96
Joined: Mon Feb 24, 2014 11:46 pm

Re: Ways to read a string one character at a time

Post by poshu »

Have you checked the type of end line encoding of your file? It could be LF, CR or CRLF. This is probably the reason it's read as joined together.

As far as memory consumption goes, I can't help you sadly :/
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Re: Ways to read a string one character at a time

Post by Jarlve »

Windows (CR LF)
Post Reply