Page 1 of 1

Read Ascii file in DataSection [Resolved]

Posted: Thu Dec 29, 2016 7:27 pm
by Kwai chang caine
Hello at all :D

Since the v5.50 we are forced to use UNICODE :|
So apparently this code not works
Is it possible to read my ASCII file including in the DataSection ?

I have searching and in 2010 Netmaestro say no...
http://www.purebasic.fr/english/viewtop ... 65#p329165
Maybe a new option born since this time, without talking it's Christmas time 8)
Or the only one method is always Peeks() in one variable, and cut it after

Code: Select all

Restore Begin
Read.s a$
Debug a$

DataSection
 Begin:
  IncludeBinary("F:\Aie aie aie\Kcc\Have\Always\Problem.txt") ; TXT in ASCII mode
EndDataSection
Have a good end of year

Re: Read Ascii file in DataSection

Posted: Thu Dec 29, 2016 8:51 pm
by helpy
I think this is not possible.
It seems that "Read.s" expects UCS2 format.

If using IncludeBinary you always should use PeekS and the parameter for the "string format":

Code: Select all

a$ = PeekS( ?AsciiString01, -1, #PB_Ascii )
Debug a$

DataSection
	AsciiString01:
	IncludeBinary("ascii_file.txt") ; TXT in ASCII mode
	Data.a #Null
EndDataSection

Re: Read Ascii file in DataSection

Posted: Thu Dec 29, 2016 9:11 pm
by Kwai chang caine
Ahhh !!! I was afraid of this answer :|
It's when even surprising that FRED not give the possibility to do that, since he have forcing to use UNICODE :shock:
It's when even not all the file who is in UNICODE
It's possible sometime, another application forcing to use ASCII
So we must convert the file before or use Peeks.... :|

So thanks to your answer 8)
And have a very good end of year :wink:

Re: Read Ascii file in DataSection [Resolved]

Posted: Thu Dec 29, 2016 9:25 pm
by helpy
I think there was a similar problem before using 5.5x:
If you compiled your program in ASCII mode and included an UTF-8 or UTF-16 formatted file with IncludeBinary, Read.s probably also did not worked.

Text files included with IncludeBinary always should have been handeled with caution, because the file was included as it is!
Read.s never tried to guess which string format has to be used.

Greeting from
Bavaria, Germany ;-)

Re: Read Ascii file in DataSection [Resolved]

Posted: Fri Dec 30, 2016 8:23 am
by Fred
Read.s is meant to be use with Data.s, if you includebinary a raw file, no wonder it won't work. It's not an unicode issue, please stop this 'ascii was better' crusade, it's really getting boring overtime.

Re: Read Ascii file in DataSection [Resolved]

Posted: Fri Dec 30, 2016 9:10 am
by helpy
Fred wrote:Read.s is meant to be use with Data.s, if you includebinary a raw file, no wonder it won't work.
That's what I thought! And the step to remove the ASCII option is understandable and I appreciate this change.

Re: Read Ascii file in DataSection [Resolved]

Posted: Fri Dec 30, 2016 9:47 am
by Kwai chang caine
My dear FRED wrote:Read.s is meant to be use with Data.s, if you includebinary a raw file, no wonder it won't work. It's not an unicode issue, please stop this 'ascii was better' crusade, it's really getting boring overtime.
I have say that because i'm surprising you have not found a solution for read an ASCII text in DATA
Apparently, it's obvious for all, but for me, not, then this is the reason of this simple question, and surprise for me.
Sure, i not understand all to this subject, and for me it's again more complicated problems, all the day

In fact, i so much not understand, that i have never writing something, before you decide to stop ASCII
You can search in the big thread about this subject, where all the members did not all agree. :shock:
Why, i have not writing ? because i not imagine all the job that give to me, since this change.
All or nearly my code not works, i'm forced to search why, and it's always a problem of ASCII-UNICODE.

So you're wrong about me, if you have decided to stop the ASCII, you have your reasons, even if i not understand all the aftermath.
I know it's less works for you, and apparently unnecessary in 2017, and i'm really happy if that can help you 8)

I am not against, but in your anger, that i see in your answer, you forget the main reason why you have created the amazing PureBasic.
PureBasic is one of the better powerfull tool of this time, but mainly, the power of PB is justly you give with your generosity and hard works, to all the little, the same power that all the master programing man like you.
So in the manner of "Robin Hood", you give to the poor, without take to the rich, because the rich give also all the days in this forum (Thanks again all the MASTERS who help the beginners all the days :wink: )

Then, please, no forget the basic reason why you have created the great PureBasic, and not be so agressive when a donkey of programming like me, even with his thousand hours of works, not understand and have a real difficulty to translate numerous API or native functions.
You are so powerfull, that you have forgotten person like me, or others, in the edge of the road in this history.
Obviously, for you, what is it this change ?? Nothing..just a W to adding in API, or #PB_ASCII in Peeks, or change a 4 in 8, or other...you do that in one second.
But for someone like me, it's hours of search, ask questions at forum friends, for just have exactely the same things i have with the v5.40 :?

Then it's not a "ascii was better crusade" like you say....but just a call of help, of unprofessional man, like numerous other in your customer base, the same ones you always attracted when you say " PureBasic has been created for the beginner" in your own site.

So i'm a beginner, and unfortunately always be a beginner, excuse me to ask or say sentences who hurt you :|
I believed that since that time, you have understand it's the last thing i want to do...even if sometime you believe i do it on purpose :oops:

I would have found useful, before you stop the ASCII, you create an help page with all the case of translate the ASCII functions to a UNICODE functions, and explain in this case, in this help what function cannot be converted, and why...

Another thing also important for the beginners :
I have all confidence in you, it's for that i follow you and all your products since more than 10 years, i believe all what you say..
But, it's not because i believe you, that in my empty head, i have no question about all your decisions....
Then please, when you take importants decisions, that be very usefull and kind, if you think at your dear "beginners" so much desired, why, and what that change, etc...

Because it's when even a pity, that this job is transferred at all the masters of this forum, who spent his time to explain all the day the fix, the reasons, the result, etc....and the worst of all this history, it's all this explanations is scattered in all the forum, then the questions is again and again asking....

Just one page in the doc, about this important subject would perhaps suffice, to stop this flood of questions...and why not, a so-called "ascii was better crusade" :wink:

I finish 2016, by making me bawl :| .......strongly 2017 for the "reboot" :mrgreen:

Have when even a good year 2017 and numerous others, MASTER of the MASTERS, FRED 8)