Open a text file with notepad on android

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
jodapecol
Posts: 9
Joined: August 25th, 2017, 9:56 am

Open a text file with notepad on android

Post by jodapecol »

Hi, a query I want to open a text file.
For example I want to open "lista.txt"
I've tried this:

Dir_existe02 = pathname (Application) + "Lists \" + "listing.txt";
1. execsystem (maketext ("app: com.example.android.notepad"));
2. execsystem (maketext ("app% s", dir_existe02));

Trying to execute the "1" was not executed and therefore neither the "2".
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Open a text file with notepad on android

Post by josh »

When you use app: with execsystem there is no way to specify an argument. It will only launch the application. Instead you can use view: with the name of the file. Then, based on the extension of the file, Android will launch the appropriate to view that type of file (kind of like when you double click on a file in Windows). So if you have notepad installed and it knows how to open .txt files then when you use execsystem with view it will launch the file in notepad or if there are multiple programs on your Android device that know how to open .txt files it will ask you which one you want to use and you can choose notepad.

The code would be:

execsystem(maketext("view:%s", dir_existe02));
Yana
Posts: 51
Joined: October 6th, 2016, 6:57 am

Re: Open a text file with notepad on android

Post by Yana »

Is it possible to run (.bat) files in Cspro? when I write out the logic to run it opens file explorer in Windows rather than executed the .bat file.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Open a text file with notepad on android

Post by Gregory Martin »

You can run batch applications (on Windows). I've used this code to run a batch application:
execsystem(maketext('"%sCreate Deployment.bat"',pathname(Application)),wait);
I would look into whether your DOS batch file is written properly. If you double-click on it in Explorer, does it run properly?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Open a text file with notepad on android

Post by josh »

It usually opens Windows explorer when the path or filename of the bat file you are launching is incorrect. I bet that you don't have the filename or path correct in your call to execsystem.
Post Reply