@@ -13,9 +13,39 @@ public EZHelp(Interpreter interpreter)
1313 Interpreter = interpreter ;
1414 }
1515 public EZHelp ( ) { }
16- public void Print ( string text )
16+ public async Task Await ( object val )
1717 {
18- text = Format ( text . ToString ( ) ) ;
18+ try
19+ {
20+ string wait = StringParse ( val ) ;
21+ if ( bool . TryParse ( wait , out bool res ) )
22+ {
23+ while ( res )
24+ {
25+ res = bool . Parse ( ObjectParse ( val , "bool" ) . ToString ( ) ) ;
26+ }
27+ }
28+ else if ( int . TryParse ( wait , out int num ) )
29+ {
30+ await WaitForMiliseconds ( num ) ;
31+ }
32+ }
33+ catch ( Exception e )
34+ {
35+ Error = e . ToString ( ) ;
36+ throw ;
37+ }
38+ }
39+ internal static async Task WaitForMiliseconds ( int mililseconds )
40+ {
41+ for ( int i = 0 ; i < mililseconds ; i ++ )
42+ {
43+ await Task . Delay ( 1 ) ;
44+ }
45+ }
46+ public async void Print ( string text )
47+ {
48+ text = await Format ( text . ToString ( ) ) ;
1949 Interpreter . Output = [ .. Interpreter . Output , text . ToString ( ) ] ;
2050 Console . WriteLine ( text ) ;
2151 }
@@ -29,13 +59,13 @@ public string Input()
2959 string input = Interpreter . ConsoleInput ( ) ;
3060 return input ;
3161 }
32- public string Format ( object _text ) => Format ( _text , "'" ) ;
33- public string Format ( object _text , object _char )
62+ public async Task < string > Format ( object _text ) => await Format ( _text , "'" ) ;
63+ public async Task < string > Format ( object _text , object _char )
3464 {
3565 try
3666 {
3767 char c = char . Parse ( _char . ToString ( ) ) ;
38- string text = ObjectParse ( _text . ToString ( ) , "str" , true ) . ToString ( ) ;
68+ string text = ( await ObjectParse ( _text . ToString ( ) , "str" , true ) ) . ToString ( ) ;
3969 string format = "" ;
4070 char [ ] chars = text . ToCharArray ( ) ;
4171 bool open = true , backslash = false ;
@@ -114,14 +144,14 @@ public string Format(object _text, object _char)
114144 }
115145 if ( Interpreter . Vars . Any ( x => x . Name == instance_name ) )
116146 {
117- format = format . Remove ( range . Start , range . Count ) . Insert ( range . Start , Interpreter . GetValue ( name , DataType . GetType ( "str" , Interpreter . Classes ) ) . ToString ( ) ) ;
147+ format = format . Remove ( range . Start , range . Count ) . Insert ( range . Start , ( await Interpreter . GetValue ( name , DataType . GetType ( "str" , Interpreter . Classes ) ) ) . ToString ( ) ) ;
118148 }
119149 else
120150 {
121151 Interpreter . parser . WatchIsFound ( [ name ] , 0 , out ExplicitWatch watch , out _ ) ;
122152
123- object val = Interpreter . GetValue ( watch != null ? watch . Runs : name , DataType . GetType ( "str" , Interpreter . Classes ) ) ;
124- format = format . Remove ( range . Start , range . Count ) . Insert ( range . Start , Interpreter . GetValue ( val , new DataType ( DataType . Types . _string , null ) ) . ToString ( ) ) ;
153+ object val = await Interpreter . GetValue ( watch != null ? watch . Runs : name , DataType . GetType ( "str" , Interpreter . Classes ) ) ;
154+ format = format . Remove ( range . Start , range . Count ) . Insert ( range . Start , ( await Interpreter . GetValue ( val , new DataType ( DataType . Types . _string , null ) ) ) . ToString ( ) ) ;
125155 }
126156 }
127157
@@ -142,8 +172,8 @@ public string StringEmpty()
142172 {
143173 return string . Empty ;
144174 }
145- public object ObjectParse ( object obj , object type ) => ObjectParse ( obj , type , false ) ;
146- public object ObjectParse ( object obj , object type , bool to_string , string arraySeperator = " " , bool returnNull = false )
175+ public async Task < object > ObjectParse ( object obj , object type ) => await ObjectParse ( obj , type , false ) ;
176+ public async Task < object > ObjectParse ( object obj , object type , bool to_string , string arraySeperator = " " , bool returnNull = false )
147177 {
148178 try
149179 {
@@ -160,7 +190,7 @@ public object ObjectParse(object obj, object type, bool to_string, string arrayS
160190 o = obj ;
161191 DataType data = DataType . GetType ( type . ToString ( ) , Interpreter . Classes ) ;
162192 if ( Interpreter . Vars . Any ( x => x . Name == n ) ) Interpreter . Vars . FirstOrDefault ( x => x . Name == n ) . DataType = data ;
163- obj = Interpreter . GetValue ( n , data , arraySeperator ) ;
193+ obj = await Interpreter . GetValue ( n , data , arraySeperator ) ;
164194 } while ( obj != o ) ;
165195 }
166196 catch when ( returnNull ) { return null ; }
@@ -462,15 +492,15 @@ public bool SameType(object a, object b)
462492 }
463493 }
464494 public int StringLength ( object str ) => StringParse ( str ) . Length ;
465- public int RunEZCode ( string code )
495+ public void RunEZCode ( string code )
466496 {
467497 try
468498 {
469499 code = ObjectParse ( code , "str" ) . ToString ( ) ;
470500 Parser parser = new Parser ( string . Join ( " " , code ) , "(instance running from inside file)" ) ;
471501 parser . Parse ( ) ;
472502 Interpreter interpreter = new Interpreter ( parser ) ;
473- return interpreter . Interperate ( ) ;
503+ interpreter . Interperate ( ) ;
474504 }
475505 catch ( Exception e )
476506 {
0 commit comments