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

#1 2010-12-28 11:16:52

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Error? I'll give you error!

Yeah, basically I have a block that reports "File ( ) in folder [ ]" and if it gets a number higher than the amount of files in the folder, I get an error. I need to display all the files in the folder though, so to do this I need to do "repeat until <[File t1 in folder t2] = []>"

but I get an error, which I can't compare!

I either need a way to get the block to report something else like '' (nothing) when the file number does not exist, or a block called (number of files in folder [ ]).

any ideas? Here's the code:

Code:

|t3|
t3_t1 asNumber.
t1_t3.
^ ((FileDirectory on: t2 asString) entries at: t1) name asString.

and with my not-working script:

Code:

|t3 t4|
t3_t1 asNumber.
t1_t3.
t4_ ((FileDirectory on: t2 asString) entries at: t1) name asString.

t4 = 'error!' ifTrue: [^''] ifFalse: [^t4].

http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2010-12-28 11:37:53

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Error? I'll give you error!

Code:

|t3|
t3_t1 asNumber.
t1_t3.
[^ ((FileDirectory on: t2 asString) entries at: t1) name asString.]
ifError: [^ '(nothing)']

The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#3 2010-12-28 11:46:31

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Error? I'll give you error!

ahhhhhh..... I will learn from this, thanks!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#4 2010-12-28 11:51:10

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Error? I'll give you error!

Glad I could help  smile


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#5 2010-12-28 13:12:20

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Error? I'll give you error!

I'm working on a file browser, and since I want to do thumnails, is there a way I can make all image sizes be displayed as a same size thumb? e.g. a "sprite height" and "sprite width" reporter? Then I could set stretch effect to sprite width / width of square or something like that!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#6 2010-12-28 13:17:14

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Error? I'll give you error!

Code:

(Form fromFileNamed: t1) width

Code:

(Form fromFileNamed: t1) height

The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

Board footer