Merge pull request #43 from Rexo35/patch-1

Add the "ZS.System.Command" function
This commit is contained in:
sam-astro 2022-08-28 12:43:50 -04:00 committed by GitHub
commit c8f51e0c94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,14 @@
#ifndef BUILTIN_H #ifndef BUILTIN_H
#define 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 <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>
@ -13,6 +21,7 @@
#include <ctime> #include <ctime>
#include <math.h> #include <math.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <cstdlib> // for console command printing
#include "strops.h" #include "strops.h"
#include "graphics.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))); Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)));
return v; 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 else
LogWarning("ZS function \'" + name + "\' does not exist."); LogWarning("ZS function \'" + name + "\' does not exist.");

View File

@ -0,0 +1,5 @@
func Main()
{
Printl("this is a test:")
ZS.System.Command("cls")
}