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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode