Shell - argv parameter with SPACE

JB sundown at pacifier.com
Sat Jun 24 23:12:49 EDT 2017


Hi Richard,

There are plenty of free compilers.  Xcode will
compile c, c++, and objective-c.  To compile
from the terminal you can use gcc which is a
really good compiler.

What the code provided does it it gives you the
ability to use c, c++, objective-c, and Java code
in your Livecode stacks.

For those who have a basic understanding of any
of these languages there is a lot of code on the
web they can use with little of no changes giving
them a lot of extra power with little effort.

These examples are the MAIN LINK to using other
code within Livecode.

I understand a lot of people do not know or want to
know other languages and this code is aimed at the
few people who do now or will in the future.

Providing this ability can attract programmers who do
not use Livecode now but know other languages and
want to use their knowledge with Livecode.

JB


> On Jun 24, 2017, at 7:50 PM, Richard Gaskin via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> JB, a few of these snippets have been posted to the list, but with no explanatory text.  Were these intended for someone else?
> 
> If you meant to send them here, for the benefit of those of us who may not have ready access to an Objective-C compiler, would you mind offering some description of what we should be learning from these?
> 
> -- 
> Richard Gaskin
> Fourth World Systems
> 
> 
> JB wrote:
> 
> 
>> Compile the following objective-c code as argv_nsstring-1
>> 
>> #import <Foundation/Foundation.h>
>> 
>> int main(int argc, const char * argv[]) {
>>    @autoreleasepool {
>>        NSString *arg1 = [NSString stringWithUTF8String:argv[1]];
>>        NSString *arg2 = [NSString stringWithUTF8String:argv[2]];
>>        NSString *arg3 = [NSString stringWithUTF8String:argv[3]];
>>        NSLog(@"\nArgument 1: %@\n", arg1);
>>        NSLog(@"\nArgument 2: %@\n", arg2);
>>        NSLog(@"\nArgument 3: %@\n", arg3);
>>    }
>> 
>>    return 0;
>> }
>> 
>> 
>> Enter the following code in a button;
>> 
>> on mouseUp
>>   set the defaultFolder to "~/Desktop"
>>   put "ONE TWO THREE" into tFILE
>>   put shell( "./argv_nsstring-1" && tFILE) into pData
>>   put pData into fld id <YOURFIELD>
>>   beep 2
>> end mouseUp
> 
> 
> 
> 
>> ompile 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
> 
> 
> 
> 
>> on mouseUp
>>   set the defaultFolder to "~/Desktop"
>> 
>>   /* ADD SPACES IN ARGUMENTS BY USING QUOTE */
>>   --put "One" into tFILE1
>>  // Below I added a space in the filename before the word copy.
>>   put quote & "/Users/JB/Desktop/SomeFile copy.jpg" & quote 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 <YOURFIELD>
>>   beep 2
>> end mouseUp
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list