mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2026-02-03 22:52:12 +00:00
Merge pull request #43 from Rexo35/patch-1
Add the "ZS.System.Command" function
This commit is contained in:
commit
c8f51e0c94
@ -1,6 +1,14 @@
|
||||
#ifndef BUILTIN_H
|
||||
#define BUILTIN_H
|
||||
|
||||
#if defined(__unix__)
|
||||
#define UNIX true
|
||||
#define WINDOWS false
|
||||
#elif defined(_MSC_VER)
|
||||
#define UNIX false
|
||||
#define WINDOWS true
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@ -13,6 +21,7 @@
|
||||
#include <ctime>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdlib> // for console command printing
|
||||
|
||||
#include "strops.h"
|
||||
#include "graphics.h"
|
||||
@ -467,6 +476,13 @@ boost::any ZSFunction(const string& name, const vector<boost::any>& args)
|
||||
Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)));
|
||||
return v;
|
||||
}
|
||||
else if (name == "ZS.System.Command"){
|
||||
string command = StringRaw(AnyAsString(args.at(0)));
|
||||
//int command_len = command.length();
|
||||
//char* command_char_arr=new char[command_len + 1];
|
||||
//strcpy(command_char_arr, command.c_str()); // string into char arr
|
||||
int k = system(command.c_str());
|
||||
}
|
||||
else
|
||||
LogWarning("ZS function \'" + name + "\' does not exist.");
|
||||
|
||||
|
||||
5
examples/console_application.zs
Normal file
5
examples/console_application.zs
Normal file
@ -0,0 +1,5 @@
|
||||
func Main()
|
||||
{
|
||||
Printl("this is a test:")
|
||||
ZS.System.Command("cls")
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user