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

by Jarlve Thu Jun 28, 2018 8:38 am

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: 553
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

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

by Peter Thu Jun 28, 2018 8:52 am

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

by Jarlve Thu Jun 28, 2018 10:46 am

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: 73
Joined: Mon Feb 24, 2014 11:46 pm

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

by poshu Thu Jun 28, 2018 12:03 pm

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

by Jarlve Thu Jun 28, 2018 8:15 pm

Windows (CR LF)
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 5 guests