Sign in to follow this  
Followers 0
HardCopy

_Filereadtoarray

3 posts in this topic

Example small text file called test.txt or whatever.

File contains 5 lines of numbers 1 2 3 4 5 etc

run this snippet

#include <GuiConstants.au3>
#include <array.au3>
#include <file.au3>

 Dim $RetArray = ""
  _FileReadToArray("C:\test.txt",$RetArray)

_ArrayDisplay($RetArray,"Test")

Output shows

[0]=6 <--- Yup looks good

[1]=1

[2]=2

[3]=3

[4]=4

[5]=5

[6]= <--Not Good <----- @ Blank Element CRLF???

7 elements index says 6

no trailing linefeed in my text.

currently im redimming on the index[0] to work round it

This blank elemnt looks suspect to me. If i am wrong will someone educate me as to its purpose.

Thanks

HardCopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites



Example small text file called test.txt or whatever.

File contains 5 lines of numbers 1 2 3 4 5 etc

run this snippet

#include <GuiConstants.au3>
#include <array.au3>
#include <file.au3>

 Dim $RetArray = ""
  _FileReadToArray("C:\test.txt",$RetArray)

_ArrayDisplay($RetArray,"Test")

Output shows

[0]=6 <--- Yup looks good

[1]=1

[2]=2

[3]=3

[4]=4

[5]=5

[6]= <--Not Good <----- @ Blank Element CRLF???

7 elements index says 6

no trailing linefeed in my text.

currently im redimming on the index[0] to work round it

This blank elemnt looks suspect to me. If i am wrong will someone educate me as to its purpose.

Thanks

HardCopy

Guess you have @CRLF after record 5 ? (in other words, the last record in the file is also empty? )

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Guess you have @CRLF after record 5 ? (in other words, the last record in the file is also empty? )

Well JdeB, sorry for wasting your time.

I honestly thought of that before i posted here, and checked for the linefeed before saving it.

WAS using ConText for text editing, and scite for coding, dumb i know, thought i was to busy at moment to worry bout that. (Now fixed that.)

So i used Scite to save the file. Bingo No blank element.

Context was saving the extra line without my known consent.

Thanks for taking the trouble to assist.

HardCopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0