Discuss Scratch

jase1985
New to Scratch
4 posts

Support with SENSE / SCRATCH script with processing lists

Hi all, I'm hoping someone with more knowledge than myself in this area (which shouldn't be too hard) can support me with the brick wall I seem to have run in to. It's probably worth mentioning that I'm using SENSE too but I'm told SCRATH and SENSE are very similar…

As part of an assignment I've been given the following task:

To create a log file from the list pressureReadings which contains 100 sensor measurements

The first reading in pressureReadings was taken at time 1, the second at time 2 and so on. The records you create must have time values matching these times.

The part I am struggling with is getting the program to read from the list in order from 1 - 100. It wont allow me to use ‘change by’ blocks as pressureReadings is a list and not a variable. I just don't know what else to try.

I hope that makes sense (no pun intended)

Any support / suggestions will be greatly appreciated.
drmcw
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

if it was a Scratch list

set count to 1
repeat 100
do what you want with item count of list
change count by 1

That will loop through the list in order and you get the item from the list with item count from list where count is a variable.

You could do it without the variable if you don't mind deleting everything from the list with

repeat until length of list = 0
do what you want with item 1 of list
delete item 1 of list

Last edited by drmcw (July 16, 2013 19:04:33)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
scubajerry
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

Just adding to what drmcw said. Once you create a list in the data tab, a bunch of new commands pop up. One of them is ITEM ___ of list_name
That retrieves the data. If you want to change it, you have to use the REPLACE command.

You can build the list by either to an ADD for each specific piece of data you have, or you can use the ADD with dummy data and the using the REPLACE to put the specific data in the list.
Failord
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

This seems like a case for my Listwizard personna.
Look for the invisible text in my signature and a confirmation on the other profile to prove it's me.
If you need a remix showing how to do this, let me know.

Last edited by Failord (July 16, 2013 22:22:04)


Thanks for the ride, Scratch Team and community! Unfortunately, the time has come for me to move on from Scratch, so I'll no longer be using the forums. Thanks again, and farewell!
Invisible text! This will show you if a profile I claim to be mine IS mine. Just remember to visit the profile and see if I confirmed in the comments.
For old time's sake, see the revolutionary Laser Battle 2.0! Also see Unstoppable Game!

And no, the evil kumquats didn't alter my signature…
jase1985
New to Scratch
4 posts

Support with SENSE / SCRATCH script with processing lists

Thanks for the responses everyone. I still haven't cracked it yet. I can't use the replace block as it deletes items, I can't lose the variable either. I can get the program to write the first line out of the list to a text file which it does repeatedly for the length of the list (100 items). However, it's only writing that first line 100 times. It needs to write line 1, then 2 and so on…

I dont know why I can't figure it out
scubajerry
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

If you can share a link to the project, we can be more help.
drmcw
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

jase1985 wrote:

Thanks for the responses everyone. I still haven't cracked it yet. I can't use the replace block as it deletes items, I can't lose the variable either. I can get the program to write the first line out of the list to a text file which it does repeatedly for the length of the list (100 items). However, it's only writing that first line 100 times. It needs to write line 1, then 2 and so on…

I dont know why I can't figure it out

How didn't using a variable, called for example count, work as in the example above?

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
jase1985
New to Scratch
4 posts

Support with SENSE / SCRATCH script with processing lists

I will try and post a link when I get in later. Not sure why it didn't work drmcw. here's what i tried

set variable theTime to 1
set reportString to item theTime of listName
loop - until length of listName
append reportStringto myfile.txt
change theTime by 1

At least i think that's right…
drmcw
Scratcher
1000+ posts

Support with SENSE / SCRATCH script with processing lists

jase1985 wrote:

I will try and post a link when I get in later. Not sure why it didn't work drmcw. here's what i tried

set variable theTime to 1
set reportString to item theTime of listName
loop - until length of listName
append reportStringto myfile.txt
change theTime by 1

At least i think that's right…

As long as the set report string is inside the loop then it should work.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
jase1985
New to Scratch
4 posts

Support with SENSE / SCRATCH script with processing lists

Ok, so i got there in the end. Thanks to everyone who supported me, here's what I did… I thought it be best if I just upload an image. I guess I didn't explain it very clearly at the start but the important thing is that I managed to figure it out in the end!

http://www.use.com/0db9d063a10edc8db35b

Powered by DjangoBB

Standard | Mobile