Shell - Swift
JB
sundown at pacifier.com
Sun Jun 25 17:23:58 EDT 2017
Name the project args.swift
/* After Build the product is a .swift file
and can be run with Livecode.
*/
/* You can choose either */
import Foundation
//import Darwin
var x = 0;
for arg in CommandLine.arguments {
print("argument \(x) is: \(arg)")
x += 1
}
print("Number of arguments = \(x)”)
Put the following code in a button;
on arg_swift
set the defaultFolder to "~/Desktop"
--put "One" into tFILE1
put quote & "/Users/JB/Desktop/yourFile copy.txt" & quote into tFILE1
put "Two" into tFILE2
put "Three" into tFILE3
put "Four" into tFILE4
put shell( "./args.swift" && tFILE1 && tFILE2 && tFILE3 && tFILE4) into pData
put pData into fld id 342435
beep 2
end arg_swift
====================================
Version 2
Name the project command_line_swift
/* After Build the product is a Terminal App
and can be run with Livecode.
*/
import Foundation
//import Darwin
var x = 0;
for arg in CommandLine.arguments {
print("argument \(x) is: \(arg)")
x += 1
}
print("Number of arguments = \(x)")
Put the following code in a button;
on swift_arg_cl
set the defaultFolder to "~/Desktop"
--put "One" into tFILE1
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( "./command_line_swift" && tFILE1 && tFILE2 && tFILE3 && tFILE4) into pData
put pData into fld id 342435
beep 2
end swift_arg_cl
More information about the use-livecode
mailing list