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

#1 2010-08-25 09:22:23

Daffy22
Scratcher
Registered: 2008-12-15
Posts: 500+

Writing arrays to the SB file

Me and a friend are making Scratch MOD called atom for the UG and my friend has come accross this problem: How does the scratch's file I/O works and how to save two Arrays to the SB file and how to open them from the SB file. How do you do this?


http://img201.imageshack.us/img201/1784/logosmalle.png
"Spectacular - 5 Star" -  CNET.com Editor.

Offline

 

#2 2010-08-25 10:10:06

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Writing arrays to the SB file

*bump*

.:: In more detail ::.

I have two arrays called customBlocks and customActions. these can be accessed from any class by using a method i created in ScriptableScratch called customBlockArray and customBlocks: to get and set values (customActionArray and customActions: too).

these arrays need to be stored in the SB file when saving, and need to be read into the arrays when opening an SB file.

Any help (even little) is greatly appreciated.
Especially from pople who know what they're saying  tongue
smile  thanks!

Offline

 

#3 2010-08-25 14:55:19

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Writing arrays to the SB file

Hmm I dont know how Scratch saves stuff.


You can now reach me on Twitter @johnnydean1_

Offline

 

#4 2010-08-25 15:03:01

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Writing arrays to the SB file

It uses ObjStream. If you add some instance variables to the stage (you might have done this already?) and modify ScratchStageMorph's #initFieldsFrom: and #storeFieldsOn: (add the symbol in the appropriate place) they will be stored and initialized in the Stage. You can also modify the ScratchFrameMorph method #installNewProject: (maybe....I forget what it's called) you can call something to initialize them to ScriptableScratchMorph.


nXIII

Offline

 

#5 2010-08-26 03:55:51

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Writing arrays to the SB file

nXIII wrote:

It uses ObjStream. If you add some instance variables to the stage (you might have done this already?) and modify ScratchStageMorph's #initFieldsFrom: and #storeFieldsOn: (add the symbol in the appropriate place) they will be stored and initialized in the Stage. You can also modify the ScratchFrameMorph method #installNewProject: (maybe....I forget what it's called) you can call something to initialize them to ScriptableScratchMorph.

so could i just put a couple methods on the StageMorph to get and set the arrays on ScriptableScratch and edit the init and store fields to make it work, right?

Offline

 

#6 2010-08-27 11:17:13

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Offline

 

Board footer