Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with Lists including .txt files
- rophees
-
13 posts
Help with Lists including .txt files
Hi
I am stuck on a programme where I need to have my list variable start at line one on my .txt file then go on to line two of the same text file and pop up the details. The part where I am stuck is getting scratch to go to line two without using the block < Line from file >if that makes any sense
Thanks
I am stuck on a programme where I need to have my list variable start at line one on my .txt file then go on to line two of the same text file and pop up the details. The part where I am stuck is getting scratch to go to line two without using the block < Line from file >if that makes any sense
Thanks
- rophees
-
13 posts
Help with Lists including .txt files
What I am trying to say is how do i get it to programme into line one then have it go to line 2 in the .txt file
- drmcw
-
1000+ posts
Help with Lists including .txt files
Hi
I am stuck on a programme where I need to have my list variable start at line one on my .txt file then go on to line two of the same text file and pop up the details. The part where I am stuck is getting scratch to go to line two without using the block < Line from file >if that makes any sense
Thanks
Scratch doesn't have a line from file block.
- ClayChips
-
500+ posts
Help with Lists including .txt files
That my friend would be easier than you think. What I am trying to say is how do i get it to programme into line one then have it go to line 2 in the .txt file
ClayChips, once had a legendary account called fetchydog567 now just a noob. Waiting to become just the same as his old account. But now, as the time goes by, I know now that i'm not a noob! I'm back! :D
![](http://i39.tinypic.com/2mwtn9j.gif)
- rophees
-
13 posts
Help with Lists including .txt files
That my friend would be easier than you think. What I am trying to say is how do i get it to programme into line one then have it go to line 2 in the .txt file
How do I go about it then lol
![](http://scratch.mit.edu/scratchr2/static/__1376596854__/djangobb_forum/img/smilies/smile.png)
- jTron
-
100+ posts
Help with Lists including .txt files
A “list variable” isn't like an index or reference to a location in a list, it is the list itself. Scratch doesn't have the capabilities to read and write directly to .txt files, but if you shift-click on a list's watcher on the stage you can import or export to/from a text file.
To read a list line by line, try a script like this. (list) is a list, the enter you want broken up, (i) is a temporary variable, and (res) contains each broken piece of the list.
hopefully that helps![](http://scratch.mit.edu/scratchr2/static/__1376596854__/djangobb_forum/img/smilies/smile.png)
To read a list line by line, try a script like this. (list) is a list, the enter you want broken up, (i) is a temporary variable, and (res) contains each broken piece of the list.
set [i] to (0)
repeat (length of [list])
change [i] by (1)
set [res] to (item (i) of [list])
[do whatever processing you want to do here]
/repeat
hopefully that helps
![](http://scratch.mit.edu/scratchr2/static/__1376596854__/djangobb_forum/img/smilies/smile.png)
- rophees
-
13 posts
Help with Lists including .txt files
A “list variable” isn't like an index or reference to a location in a list, it is the list itself. Scratch doesn't have the capabilities to read and write directly to .txt files, but if you shift-click on a list's watcher on the stage you can import or export to/from a text file.
To read a list line by line, try a script like this. (list) is a list, the enter you want broken up, (i) is a temporary variable, and (res) contains each broken piece of the list.set [i] to (0)
repeat (length of [list])
change [i] by (1)
set [res] to (item (i) of [list])
[do whatever processing you want to do here]
/repeat
hopefully that helps
That did help and had it working fantastically, but one more quick question
![](http://scratch.mit.edu/scratchr2/static/__1376597005__/djangobb_forum/img/smilies/smile.png)
Thank you again
- rophees
-
13 posts
Help with Lists including .txt files
It's ok I have done that part now lol. Buggered on trying to get the value of a list from 1 - 12 into other lists in order of numbers. Hmmm
- rophees
-
13 posts
Help with Lists including .txt files
Think I have cracked that one now as well. Wahoo. Going well
- DotDash
-
1000+ posts
Help with Lists including .txt files
Your profile pic isn't very appropriate for and all-ages website.
My browser / operating system: MacOS Macintosh X 10.8.5, Chrome 29.0.1547.76, Flash 11.8 (release 800)
- rophees
-
13 posts
Help with Lists including .txt files
Your profile pic isn't very appropriate for and all-ages website.
There you go, That should appeal to males and females of all ages. Thanks for bringing it to my attention DotDash
- Discussion Forums
- » Help with Scripts
-
» Help with Lists including .txt files