This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-17 15:04:00

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

CSVs in lists?

Is it possible to do CSVs (comma separated variables) in a list as a single item As an alternative to parallel arrays.?


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#2 2012-06-17 15:23:29

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: CSVs in lists?

I did somthing like that in my Learning Chatbot Project. It basicly "tears up" each row to find the individual strings, using ¶ as a delimiter (or whatever they are called).


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#3 2012-06-17 15:29:32

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: CSVs in lists?

Molybdenum wrote:

I did somthing like that in my Learning Chatbot Project. It basicly "tears up" each row to find the individual strings, using ¶ as a delimiter (or whatever they are called).

I looked at the project and I's impressive. I'm still figuring what it does but I'm guessing it just iterates over the list and if it's equal to ¶ it adds what it's already iterated over to a variable?


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#4 2012-06-17 16:26:54

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: CSVs in lists?

I think it just takes the output list's item (the onpe it found), and puts the seperated data into another list, seperated. Ex.
Output: 123¶55¶I AM AWESOME
...
.Script
..-..-.
Outputlist:
123
55
I AM AWESOME

Then it can use the data.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#5 2012-06-18 12:08:44

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: CSVs in lists?

Molybdenum wrote:

I think it just takes the output list's item (the onpe it found), and puts the seperated data into another list, seperated. Ex.
Output: 123¶55¶I AM AWESOME
...
.Script
..-..-.
Outputlist:
123
55
I AM AWESOME

Then it can use the data.

Yea, that's what it does, but how is what I was talking about


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#6 2012-06-18 12:16:56

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: CSVs in lists?

Oh. It basicly has a list (Wordlist or something) and sequentially reads that characters of the to-be-seperated line. If its a ¶, it adds a black line to wordlist, else, it puts the read character onto the last line. Sort of like a text editor, if the key just pressed was enter (analogous to the ¶), add a new line, else, put the keystroke (analogous to any character besides the ¶) on the line.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#7 2012-06-18 12:21:37

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: CSVs in lists?

Whoops, typos. (and I can't edit because I'm still a new scratcher)
*sequentially reads the characters
*it adds a blank line to wordlist


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#8 2012-06-20 09:47:26

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: CSVs in lists?

Yes, it is. Try this script.

add (join (Variable 1) (join (,) (join (Variable 2) [and so on...]))) to  [List v]
You can keep doing this to add more variables.

Offline

 

#9 2012-06-20 16:44:21

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: CSVs in lists?

That won't work for a variable number of variables...


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#10 2012-06-21 08:40:02

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: CSVs in lists?

For adding to a line it seems like something like this would work? If I'm understanding what you're talking about.

if <item (1 v) of [List v] = []>
replace item (1 v) of [List v] with (Addition to row)
else
replace item (1 v) of [List v] with (join (item (1 v) of [List v]) (join (,) (Addition to row)))
end


http://i50.tinypic.com/ded8m.png

Offline

 

Board footer