User Tools

Site Tools


sample_code:introspector

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
sample_code:introspector [2014/10/11 06:24]
stevegarman
sample_code:introspector [2015/03/28 20:01]
octazid [The code] Change Database to Open
Line 4: Line 4:
 It is incomplete as it does not drill down far enough but it is much better than nothing. It is incomplete as it does not drill down far enough but it is much better than nothing.
 ===== Warnings ===== ===== Warnings =====
-Please be aware that using undocumented functions is not recommended by the AndroidScript developers and you do so at your own risk.\\+Please be aware that using undocumented functions is not recommended by the DroidScript developers and you do so at your own risk.\\
 Please also be aware that the **"Manually entered code"** option can be very dangerous. Please also be aware that the **"Manually entered code"** option can be very dangerous.
 ===== Acknowledgements ===== ===== Acknowledgements =====
-Andreas Rozek would recognize much oif the code as the heart of it is stolen from his post at [[https://groups.google.com/forum/#!topic/androidscript/o_RCNR5ozAE]]+Andreas Rozek would recognize much of the code as the heart of it is stolen from his post at [[https://groups.google.com/forum/#!topic/androidscript/o_RCNR5ozAE]]
  
 Thanks also to Salvatore Fusto for finding a bug in the app. Thanks also to Salvatore Fusto for finding a bug in the app.
Line 25: Line 25:
 var docfold = "/sdcard/sjgDocs/androidscript/"+vers; var docfold = "/sdcard/sjgDocs/androidscript/"+vers;
 var docfile = docfold + "/null.txt"; var docfile = docfold + "/null.txt";
 +var evalsfile = docfold + "/evals.txt"
  
 //Called when application is started. //Called when application is started.
Line 39: Line 40:
  
     var control_list = "app,layout,Manually entered code,Button,CameraView,CheckBox"     var control_list = "app,layout,Manually entered code,Button,CameraView,CheckBox"
-      +",Crypt,Dialog,Email,Image,List,Locator,Notification,SeekBar"+      +",Crypt,Database,Dialog,Email,Image,List,Locator,Notification,SeekBar"
       +",Sensor,SMS,Spinner,Text,TextEdit,ToggleButton"       +",Sensor,SMS,Spinner,Text,TextEdit,ToggleButton"
       +",WebServer,WebView,YesNoDialog"       +",WebServer,WebView,YesNoDialog"
Line 55: Line 56:
   /**** prepare detail view ****/   /**** prepare detail view ****/
  
-    FunctionView = app.CreateTextEdit('');+    FunctionView = app.CreateTextEdit('',-1,-1); 
 +//FunctionView = app.CreateTextEdit('',-1,-1,"nospell");
     PageArea.AddChild(FunctionView);     PageArea.AddChild(FunctionView);
     FunctionView.SetVisibility('Hide');     FunctionView.SetVisibility('Hide');
Line 112: Line 114:
     case "Crypt":     case "Crypt":
         myobj = app.CreateCrypt();         myobj = app.CreateCrypt();
 +        break;
 +    case "Database":
 +        myobj = app.OpenDatabase("MyData");
         break;         break;
     case "Dialog":     case "Dialog":
Line 161: Line 166:
         myobj=app;         myobj=app;
         lastMenu = "app";         lastMenu = "app";
-    }   +    }
   prepareFunctionList();   prepareFunctionList();
   showOverview();   showOverview();
Line 238: Line 243:
     var layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );     var layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );
     layDlg.SetPadding( 0.02, 0, 0.02, 0.02 );     layDlg.SetPadding( 0.02, 0, 0.02, 0.02 );
-    edtDlg = app.CreateTextEdit('app.CreateText( "Hello" )');+    edtDlg = app.CreateTextEdit('app.CreateText( "Hello" )',-1,-1,'NoSpell');
     edtDlg.SetCursorPos(edtDlg.GetText().length);     edtDlg.SetCursorPos(edtDlg.GetText().length);
     layDlg.AddChild(edtDlg);     layDlg.AddChild(edtDlg);
Line 257: Line 262:
     dlg.Dismiss();     dlg.Dismiss();
     myobj = eval(edtDlg.GetText());     myobj = eval(edtDlg.GetText());
-    prepareFunctionList(); +    if ((myobj != null) && (myobj.hasOwnProperty("GetType"))){
-    showOverview(); +
-    if ((myobj != null) && (myobj.hasOwnProperty("GetType")))+
       lastMenu = myobj.GetType();       lastMenu = myobj.GetType();
-    else+      app.WriteFile(evalsfile, edtDlg.GetText()+"\n","append"); 
 +    } 
 +    else{
       lastMenu = "Eval";       lastMenu = "Eval";
 +    }
     main_header_txt.SetText( lastMenu );     main_header_txt.SetText( lastMenu );
 +    prepareFunctionList();
 +    showOverview();
 }//dlg_ok }//dlg_ok
 function dlg_canc(){ function dlg_canc(){
Line 272: Line 280:
 </code> </code>
  
-I have placed an spk of this app at [[http://hudl.sgarman.net/public/spk/SJGinspect.spk]] which should create a project in the AndroidScript IDE for you.+I have placed an spk of this app at [[http://hudl.sgarman.net/public/spk/SJGinspect.spk]] which should create a project in the DroidScript IDE for you.
  
-And for the sake of completeness, there is an apk at [[http://androidscript.sgarman.net/apk/SJGinspect.apk]] which you could download and install if your device is set up to allow apks that don't come from Google Play.+And for the sake of completeness, there is an apk at [[http://droidscript.sgarman.net/apk/SJGinspect.apk]] which you could download and install if your device is set up to allow apks that don't come from Google Play.
sample_code/introspector.txt · Last modified: 2015/03/29 05:06 (external edit)