First time here? Check out the FAQ!
x

Cast a smallInteger asString?

+1 vote
364 views
I'm looking to create a bunch of audio samples via iteration, and I'm getting errors ("the samples file is being recorded to more than once in this Sound.") with regard to trying to write over files with the same name. I tried using my index value (smallInteger) to add to the filename (& i asString) but I cannot cast smallIntegers into Strings this way. I also tried (suffix: i) but it seems this is reserved for creating arrays of HotValues?  Is there a way to use my index value (smallInteger) to incremental alter my audio files that I'm recording into?

And perhaps I'm attacking the problem in the wrong way. I may need to first establish empty file containers to write into first...
asked Oct 25, 2016 in Capytalk & Smalltalk by jonbellona (Adept) (1,300 points)
Could you not use MemoryWriters and readers to do the overwriting? (If I'm understanding what it is that you want to do)

1 Answer

+1 vote

Hi Jon, you're really close on the string concatenation.  If you use on of the following:

aFileName & i

or

aFileName, i printString

you'll concatenate a number string onto the end of your string.  (Depending on where this appears, it may also require literal brackets around it, for example:

{1 to: 4 collect: [:i | 'aFileName', i printString]}

answered Oct 25, 2016 by ssc (Savant) (127,060 points)
Thanks! Totally worked. I was trying to record multiple files into one buffer, so I have a different problem. I fixed that issue by creating multiple files to read, and then saved out using the string concatenation you suggested. Worked. Cool!
...