ok here goes.
im trying to make a progamme that will automatically help my wife with her organisation skills. I need it to open a txt file which has 5 lines. Each line has a series of numbers seperated by , when it has opened up th file i need it to seperate the numbers to different lists. for example. the line has:
2459, 5486, 74, 456, etc there will be 4 numbers per line, i need each number to go to too
a differernt list, so 2459 goes to guestsattendinglist, 5486 guestsinvited list, 74 goes to medicalproblemslist, and 456 goes to vegetarianlist.
what would work for me to get that to do this but to inclusde new lines as they were added in. it will increase to most likely 100 lines but could be more.
Offline
Scratch can't open other files, but panther (a popular mod) can.
Offline
shadowmouse wrote:
Scratch can't open other files, but panther (a popular mod) can.
Yes, that's true, though since this is a .txt file, you can always copy and paste the text into an ask prompt.
To barneyrubbl:
Anyway, just to make sure, you won't always have the same amount of lines each time? I know that in this example, there's 5 lines, though once you start using it in real-life, will you always have a set amount of lines?
With regards,
ErnieParke
Offline
This is possible through Scratch, but you must right click a list to import it.
INCOMING WALL OF TEXT
In this example, you'll need five lists in which the order stated above DOES MATTER, so I made it like what you stated it to be. Also note that there must be a space inbetween commas. Setup: w, x, y, z Where:
- w = Guests Attending - x = Guest Invited - y = Medical Problems - z = Vegetarian
Variables Used:
- i: Represents the current letter in the line. - i2: Represents the current line. - i4: Represents the w, x, y, z (see above).
Lists Used:
- Import: Import the .txt file here. - Guest Attending: w - Guest Invited: x - Medical Problems: y - Vegetarian: z
Script (Green Flag to Activate):
green flag delete [all] of [Guest Attending] delete [all] of [Guest Invited] delete [all] of [Medical Problems] delete [all] of [Vegetarian] set [i] to [1] set [i2] to [1] set [i4] to [1] repeat (length of [Import]) repeat (4) if (i4) = [1] add [] to [Guest Attending] if (i4) = [2] add [] to [Guest Invited] if (i4) = [3] add [] to [Medical Problems] if (i4) = [4] add [] to [Vegetarian] repeat until <<(letter (i) of (item (i2) of [Import])) = [,]> or <<(i4) = [4]> and <(i) > (length of (item i2 of [Import])>>> if <(i4) = [1]> replace item (i2) of [Guest Attending] with (join (item (i2) of [Guest Attending])(letter (i) of (item (i2) of [Import]))) if <(i4) = [2]> replace item (i2) of [Guest Invited] with (join (item (i2) of [Guest Invited])(letter (i) of (item (i2) of [Import]))) if <(i4) = [3]> replace item (i2) of [Medical Problems] with (join (item (i2) of [Medical Problems])(letter (i) of (item (i2) of [Import]))) if <(i4) = [4]> replace item (i2) of [Vegetarian] with (join (item (i2) of [Vegetarian])(letter (i) of (item (i2) of [Import]))) change [i] by (1) change [i4] by (1) change [i] by (2) set [i] to [1] set [i4] to [1] change [i2] by [1]
Breaking this up bit by bit:
Part A: - [lines 2-5] Clears previous work - [lines 6-8] Sets up variables Part B: - [lines 11-18] Adds a blank line according to the type of problem it is processing ( w, x, y, z -- see above ) Part C: - [lines 20-27] Writes out the piece of string, letter by letter, with variable *i* according to the variable *i4* Part D: - [line 29] Changes type ( w, x, y, z -- see above ) - [line 30] Changes variable *i* so that it skips the comma and space Part E: - [lines 31-33] Resets variables *i* and *i4* for a line change in variable *i2* **Repeats used based upon need, try to figure it out -- exception needed in line 19 due to the lack of a comma at the end.
Project [link]
Offline