Shell - C++

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Shell - C++

Mark Wieder via use-livecode
Compile the following C++ code as argv_c++

#include <iostream>

// When passing char arrays as parameters they must be pointers
int main(int argc, char* argv[]) {
    if (argc < 5) { // Check the value of argc. If not enough parameters have been passed, inform user and exit.
        std::cout << "Usage: Enter 4 Arguments & try again.\n"; // Inform the user of how to use the program
        exit(0);

    } else { // if we got enough parameters...
        std::cout << argv[0] << "\n";
        for (int i = 1; i < argc; i++) { /* We will iterate over argv[] to get the parameters stored inside.
                                          * Note that we're starting on 1 because we don't need to know the
                                          * path of the program, which is stored in argv[0] */
   
            std::cout << argv[i] << "\n";
        }
       
        return 0;
    }
}


Enter the following code in a button;

on mouseUp
   set the defaultFolder to "/Users/JB/Desktop/"
   
   /* DO NOT USE ANY SPACES IN ARGUMENTS */
   put "One" into tFILE1
   put "Two" into tFILE2
   put "Three" into tFILE3
   put "Four" into tFILE4
   put shell( "./argv_c++" && tFILE1 && tFILE2 && tFILE3 && tFILE4) into pData
   put pData into fld id 342435
   beep 2
end mouseUp

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...