Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with Lists including .txt files
- rophees
- New to Scratch
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
- New to Scratch
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
- Scratcher
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
- Scratcher
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
- rophees
- New to Scratch
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
- jTron
- Scratcher
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
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
- rophees
- New to Scratch
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 is there a way of programming scratch to import the .txt file to the list from a stack?
Thank you again
- rophees
- New to Scratch
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
- New to Scratch
13 posts
Help with Lists including .txt files
Think I have cracked that one now as well. Wahoo. Going well
- DotDash
- Scratcher
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
- New to Scratch
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