Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 Sys.Exec Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message

PostPosted: Tue Sep 24, 2002 4:36 pm   Post subject: Sys.Exec Help

I'm new here, and just looking for some help.

I'm writing a program to help some guys out with their online radio, Right now, they are using an IRC code to read requested songs from a playlist.txt file into Winamp to be streamed.

I wrote a program to do this (and some other things too, but they are not important) and it works fine on my computer. However, once I sent the program to the DJ of the radio, it does not work properly. Here's the weird part:

I used the code: e := Sys.Exec ("\"" + winampdirectory + "winamp.exe\" " + "\"" + albumdirectory + albumtrack + "\"")

This should use a command line with the following inputed:
"c:\program files\winamp\winamp.exe" "d:\GameMusic\album\track.mp3"

(note that the album\track.mp3 do change for different songs.) A DOS prompt flashes on the screen for a split second and close immediately and will open the selected track with winamp.

Anyways, it works fine on my computer, but on my friend's, nothing happens! I put extra little "put" statements to see if the program was actually running that line, and it is.

Want to know something weirder? If I make a slight modification to that and make it run this:
"c:\program files\winamp\winamp.exe" /ADD "d:\GameMusic\album\track.mp3"

This, will add the selected track to the currently playing winamp playlist. This works on my computer... AND my friends as well! I don't see how this could work and not the former line of code.
We speculated that it might have something to do with the fact that he's running Windows 2000 and I'm on 98... but I don't see this being the problem.

AND if we manage to fix that, there's one more problem. Many of the songs have long path & file names. i.e. "d:\GameMusic\The Legend of Zelda Ocarina of Time - Hyrule Symphony\13. Legend Of Zelda Medley.mp3|288"

I found out that if the names are too long that the DOS prompt that runs the command line will NOT open!! In fact, I tried with one where the "album\track.mp3" was 72 characters long... it worked fine. But, at 73 characters, the DOS prompt just stayed on the screen with the program directory currently opened in the command line. And at 74 or above, the DOS prompt simply did not even open. Also, the variable "e" mentioned above, when the prompt fails to work is equal to "-1". I don't know what that means in terms of errors though. And on my friend's computer, when the song should load because it's below the 72 count (but it still doesn't), he get's an "e" value of "1". I don't know what this means in terms of errors or what it's trying to tell me.

Do you have any thoughts on this at all? Is there a better method for running a similar command line without the Sys.Exec? Any help ASAP would be very much appreciated as the IRC script is constantly crashing and skippings songs.

Also, here's my source code for the program. I'm really sorry, but I have poor habits when it comes to naming variables and putting in comment tags. So...good luck trying to decipher the code...sorry again.

Most of the code in there is for other stuff you need not be concerned about (like choosing random songs, working with a recently played list, etc. etc.) It's really only the Sys.Exec I'm worried aboot.

Thanks a million. I hope we can get this program working because quite a bit of people are listening to this Final Fantasy Radio (plays other video game music too) a lot. Thanks again, and sorry for any hassles.

PostPosted: Wed Sep 25, 2002 9:41 am   Post subject: (No subject)

Welcome to SWAT,

I don't know much about Sys. but I'll try to help you out with some things. I'll also tell Dan to look into this, he has more experience in this field.

First of all, the path names could differ between Windows 98 and 2000, but I'm not sure. They might work a bit different.

Also, conserning long file names. It seems you're using DOS version of turing and it has a lower limit for long names. If you're to get a Windows version of turing, that might solve that problem. In WinOOT string limit is 255 characters. And the fact that its DOS turing it might alter path name cuz it uses all those ~2Blah.

Another idea - if you can start up Winamp by iteself, is there a way (perhaps somewhere in winamp options) to start playing the playlist? Because if that works, then instead of calling Winamp path + filename you can just alter playlist itself.

Well I'm not much of a help in this feild, we'll see what Dan has to say. Also, if you want, I can look into this using C/C++ (there are free compilers), but it might take a bit of time. Tell me if you want me to do that.
Latest from Tony's programming blog. DWITE - a programming contest.

PostPosted: Wed Sep 25, 2002 1:08 pm   Post subject: ok, i will try to help

ok, 1st i think there is a difrents from win 98 to 2000. i dont have 2000 so i whode not know.

2nd basckily the sys.exec comand wroks just like you where in dos proment so if your frends dir for winampt conats names that are to long you may be geting some porblems.

i once made a progame to covert win file names to ones that can be used by dos. i think it whent like this:


%vars for logo.t
var filelocationb : string := Dir.Current %find out the curent dirceory
var cuch, filelocation : string := ""
var woradcu, fix : int := 0
var temploc : string := ""

procedure runfile (filesname : string)
    filelocationb := Dir.Current %find out the curent dirceory
    %loop to covert of the dir location to a valied dos location
    for filel : 1 .. length (filelocationb)
        cuch := filelocationb (filel) %brak up the dir to anils it

        %find out where the names of the folads begain and where they end
        if cuch not= "/" and cuch not= " " then
            woradcu += 1 %keep trace of how many leters there are in the name
        elsif cuch = "/" then %if it is a new name rest couter
            woradcu := 0
            fix := 0
        end if

        %if there are to many leters in a foraled and/or file
        %chage it in to a valed dos name
        if woradcu > 8 then
            if fix = 0 then % if the name has not allready been fixed
                cuch := "~1" %thingy to put on the end of long file names
                fix := 1 %tell porgame that this name has been fixed

                %loop to brak down dir location and fix the file name
                for file2 : 1 .. length (filelocation)

                    %store the dir loaction with out the last 2 chatres
                    %in a temp loaction so it can be cahged then put
                    %back in it's right var
                    if file2 < length (filelocation) - 1 then
                        temploc += filelocation (file2)
                    end if
                end for

                filelocation := temploc %put the new loaction back
                temploc := "" %reset the temp var
                cuch := "" %reset the var so nothing is overwiten
            end if
        end if

        %check to see if the dir has the righ slashs and spaceing
        if cuch not= "/" and cuch not= " " then %if it dose
            filelocation += cuch %add the chareter as it is
        elsif cuch = "/" then %if it is not the right slash
            filelocation += chr (92) %add the right slash
        end if
    end for

    %play the file with the right dos dir
    var logoplay : int := Sys.Exec (filelocation + chr (92) + filesname)

end runfile

ok this code was made for somting a lite difrent then what you are doing so you will have to mod it a bit. what that code dose is it makes a procedure that will take a dos file name and will run it form the curent dir turing ruing the turing file in.

what you will need to do is use the part of this code that coverts the dir for the flie to a dos dir.

also i whode sugest geting turing 4.0.4 or 4.0.3 wich has just came out it has a new sys.exec comand that will wrok better and turings 4.0.3 and 4.0.4 can comiple unlike 4.0.1 and 4.0.0.

i was not 100% shure what you where asking so if i did not help plz post agen and i will try to help ferther. aslo if i think of anything eletes that will help i will post it.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!

PostPosted: Wed Sep 25, 2002 1:55 pm   Post subject: (No subject)

Well...thanks...but this doesn't help too much...

First off, I am using WinOOT for this... version 3.1.1 I think. Where can I get 4?

There's no problem with the 255 character limit, none of the song path/filenames even come close to that (probably 100 characters long is the most). But...altering the playlist file and then just having winamp reopen that playlist is a good idea too... I'll look into that; that would definitly solve the 72 evil character thing of death. I think that would work.

But, there still remains one problem. When I run the Sys.Exec to load something in winamp, i.e. "c:\program files\winamp\winamp.exe" "c:\playlist.m3u"
it still won't load on my friend's computer. HOWEVER, if I slightly alter it to read: "c:\program files\winamp\winamp.exe" /ADD "c:\playlist.m3u" it WILL load properly... I don't know why this is... the first command line loads fine on my computer but not my friend's...and hte second one loads fine on both computers.

The deal is that I have to reload this playlist file for each song change. (the program loads each song once the other old one finishes)

So, so long as I can figure out why the command line won't work for the "c:\program files\winamp\winamp.exe" "c:\playlist.m3u"

BTW... Turing rocks!

PostPosted: Wed Sep 25, 2002 2:35 pm   Post subject: (No subject)

hey FizixMan,

I think I figured out a solution to your problem. The thing about Sys.Exec is that not only it starts programs, it also loads files through their default program according to their format.

Basically in other words, if you set winamp as your default MP3 player, and in Sys.Exec() you put the file name, that song will get loaded into winamp.

I worked for me, I hope it will work for you and your friend.
var i:boolean
i:= Sys.Exec("filename.mp3")

Things to watch out for - make sure that winamp is not loaded as a new application with each song... it will get really laggy after you load it few times.

Also, during my testing, I experienced some problems with spaces (or perhaps other characters) in file names. So if the file will not load, try to rename it to something more simple.

Hopefully this is what you're looking for.

Oh, and if you really like turing, perhaps you might want to learn some other languages. You'll be amaized with what high-level languages can do - C-series, Visual Basic, Java.
Latest from Tony's programming blog. DWITE - a programming contest.

PostPosted: Thu Sep 26, 2002 9:02 am   Post subject: (No subject)

I learned Visual Basic in a grade 11 course (I was in gr12 at the time and already knew Turing by then, so I was like, better than the VB teacher Very Happy ) Now, I just need to get a VB programming environment to code in. My friend here in the University Res has one.

And I just started taking a Computer Science course in Java too.

But Turing still rules. lol, I made a program to find the inverse of a matrix last year... let's just say that Turing's round off errors were...umm...horrible for a 1000x1000 matrix Sad

I'll try that last suggestion too.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to: