Page 1 of 1

Ways to read a string one character at a time

Posted: Thu Jun 28, 2018 8:38 am
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.

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

Posted: Thu Jun 28, 2018 8:52 am
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

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

Posted: Thu Jun 28, 2018 10:46 am
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

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

Posted: Thu Jun 28, 2018 12:03 pm
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 :/

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

Posted: Thu Jun 28, 2018 8:15 pm
by Jarlve
Windows (CR LF)