Re: Borland c++ - Spawn Function

This is a discussion on Re: Borland c++ - Spawn Function within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm using borland c++ builder, and i'm trying to get the spawnl function to work correctly. At the moment ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    Re: Borland c++ - Spawn Function

    Hi,

    I'm using borland c++ builder, and i'm trying to get the spawnl function to work correctly. At the moment i am trying to execute masm assembler, so to compile assembly code from a text editor i created.
    i have enter:

    int result;
    result = spawnl(P_WAIT,"masm.exe","/z /zi /zd /l *.asm",NULL);

    The *.asm is causing masm to assemble ALL files in the folder. As the
    number of .asm files increases masm reaches a limit (somewhere around 8files) and cannot assemble any more.

    In the short term, I remove some .asm files from the folder (store themsomewhere else).

    In the long term however I need to find out how to get at the filename I am working on so to direct spawnl(...) to only assemble one file.

    I would be very grateful to any suggestions of how to overcome this problem.
    icc_81

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    Code:
    char cmdline[100];
    sprintf( cmdline, "/z /zi /zd /l %s", current_asm_file );
    result = spawnl(P_WAIT,"masm.exe",cmdline,NULL);
    current_asm_file being a string containing the file you're working on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    RE: Borland c++ spawn function

    Thanks for trying to help,

    but the same thing still happens, unfortunately i can not specifiy one single .asm file because i need the editor to be able to open more than one (this is why i use the "*.asm").

    It still will only create the list and object files of the asm file when only one asm file is saved. The minute more than one is saved it will not create the list and obkect file of any.

    Any other suggestions would be very much appreciated.
    icc_81

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    So what.

    You're got 10 asm files open, but you're only editing one at once, and that's the one you use to generate the spawn() call when you press "Assemble now".

    If you've got several files modified with a global edit, then you also have "Assemble all" to complement the "save all" feature.
    Code:
    sprintf( cmdline, "/z /zi /zd /l %s", current_asm_file );
    strcat( cmdline, another_asm_file ); /* etc */

    It sounds to me like you'd be better off if you just made your editor invoke "make", and let it handle all the details of deciding what files need to be re-created.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    Re: Assembling using spawn

    Hi again,

    I've attached my code so you can see what i'm trying to achieve. The assemble function still is not working correctly. I'm trying to use my windows based editor to assemble a .asm file that i open in it with a dos based assembler (using spawn).

    I realise that *.asm does not work so i tried converting the filename (that has been loaded) into a char (rather than a AnsiString) and calling it in the spawn function, however spawn seems to pass over the filename i want to assemble because it is now just a char function.

    Ideally i want to be able to pass the filename to a console type c function such as spawnl and then for masm to get the filename and assemble it to create the .lst file and .obj

    Again.. any help would be greatly appriciated.
    Attached Files Attached Files
    icc_81

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    It's quite obvious that you haven't paid any attention to what I've said already.

    > result = spawnl(P_WAIT,"masm.exe","/z /zd /zi /l cmdline",NULL);
    Now tell me how you managed to get that from this?

    sprintf( cmdline, "/z /zi /zd /l %s", current_asm_file );
    result = spawnl(P_WAIT,"masm.exe",cmdline,NULL);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Nov 2003
    Posts
    12
    Like i said earlier that did not work.

    I'm trying to run a windows based editor but to assemble with a dos based assembler (masm) the spawn function does not recognise the cmdline, where the asm file is, therefore it is not assembling and not creating the list or object files, of the asm file i have opened.
    icc_81

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    > Like i said earlier that did not work.
    Which one, mine or your mangled version?

    sprintf( cmdline, "/z /zi /zd /l %s", current_asm_file );
    printf( "Command line params = %s", cmdline ); // put this up in an OK dialog if you're still stuck!!

    result = spawnl(P_WAIT,"masm.exe",cmdline,NULL);

    Or better yet, start to learn how to use a debugger
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Nov 2003
    Posts
    12

    Re: c++ spawn function

    your code does not work...

    it all compiles fine but the spawnl ('masm') does not seem to be able to see the file i'm trying to assemble when the parameter are passed to it. It's no good calling that one file because i want to be able to assemble other files that i may open individually.

    the code is so 'mangled' as you say, because me and my project tutor have been trying many different ways to overcome this problem,

    i'm guessing he has an idea of how to use the debugger...but maybe all his many years of teaching are no good!!
    icc_81

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  5. help needed with spawn function
    By tsarena in forum C++ Programming
    Replies: 2
    Last Post: 05-14-2002, 11:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21