number to string conversion

In this category you can exchange your programming questions and solutions.
Post Reply
edexter
Posts: 5
Joined: Tue Nov 08, 2005 3:00 pm

number to string conversion

Post: # 352Post edexter
Mon Oct 27, 2008 2:39 pm

I am converting (or trying to convert) a rapidq example that generates a sound and plays it..

dim soundstream as memorystream
` I came up with taking the first letter off of many of thier commands and simple replacement

soundstream.writenum(44100, ?4)
soundstream.writenum(1, 2)

I think I have conversion routines for those but I get

soundstream.writenum(num,2)

where num is two bytes with a decimal and I didn`t see a conversion routine.
that allows me to write it as

soundstream.write()


thanks for the help in advance, it will make a cool example.





Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

number to string conversion

Post: # 353Post Marco
Mon Oct 27, 2008 4:49 pm

Hi, you can only write strings to a stream but you can covert the numbers with
chr$(num)  byte 1 byte
mkw$(num) word 2 bytes
mki$(num) integer 4 bytes
mkd$(num) double 8 bytes
mks$(num) single  4 bytes
they give a byte reprensative of the number, to save a 10000 and a 2 you can do
write(mkw$(10000)+chr$(2)

best regards

Post Reply