Richard Goodman wrote: > > While were on the topic of the Sound ManagerS > > The following statement occurs in Hommel's Sound Tutor program as modified > by Alain Pastor: > > cmd = song[index] > > I am in the process of incorporating Hommel's code into Sebastian and > transforming it into a somwhat different form that is more compatible with > my approach. > > I have tried to understand the above statement by looking for something > similar in the reference manual. Here is what I think is going on: > > "cmd" is a variable that has been dimensioned as CHAR. I don't know what > CHAR stands for, but I believe that it is an ASCII number for a character, > e.g. 115 for the letter s. Is that correct? RiCHARd, CHAR is a synonym for BYTE (8 bits). > > "song" has been dimensioned as a STR255. A string can be seen as an array of bytes. Each item in that array can be accessed individually thanks to the bracket syntax that allows us to use an index indicating the position of the character. The first item in that array represents the length of the Pascal string (the number of chars currently used in the string). Thus, song[0] gives the number of characters contained in the string named song; song[1] gives the ASCII code of the first character in the string; and so forth. the following statement: cmd = song[1] is equivalent to: cmd = ASC(MID$(song,1,1)) > > "index" is a short integer. > > What I think this statement does is to PEEK the character in the song > string at the position in the string determined by "index" and put the > ASCII code for that character in the variable "cmd". > right, except I would write PEEK the ASCII code of the character in the song... to make the things clearer. > Can someone tell me if my interpretation is correct? > If I am not correct, can someone interpret the statement for me? > If my interpretation is correct, can I use the same syntax with a container? > You get it right. But you can't use the bracket syntax with containers. Well, I have not even tried, but I doubt it would work. Instead, you still can use the enhanced MID$$ function to achieve the same goal. cmd = ASC(MID$$(song$$,1,1) > I am storing my melodies as containers rather than strings because they are > may be longer than 255 characters. > > In other words, if "song" were dimensioned as a CONTAINER would the > statement cmd = song[index] still be valid? > > TIA for any help on this. > You're welcome. -- Alain ----------------------------------------------------- FB^3 in Europe: http://euro.futurebasic.com/ FB II Pouch: http://www.pixmix.com/FB/outils.html -----------------------------------------------------