You are not logged in.

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

1

Monday, July 29th 2013, 7:18pm

Shell

I know how to use the Shell command and it works well.
I have already in VB used a ShellExecute command. I think however it is a call to the Kernal.
That probably won't work in a multi platform language like Java.
It loads and runs an App by loading a file that has the associated extension like .pdf or such.
Is there something equivalent in Jabaco?

I have already used Jabaco's Shell Command to a similar effect.
SN = "Write.exe /L " & Chr(34) & FN & Chr(34)
Shell (SN )

That works Ok when you know that the system that your app is operating on has a Write.exe System application.
However when you don't know the system that the end user will be using, that may not work as well.

This post has been edited 1 times, last edit by "Perry" (Jul 29th 2013, 7:25pm)


Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

2

Friday, August 2nd 2013, 3:05pm

There is a Java Example that I found Online, but I'm not good enough at Java to convert this to Jabaco.
I'm going to try though.... maybe I'll learn something.

I found it at:
https://gist.github.com/matthewmccullough/46017


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
/**
 * A Java method to execute and wait for a shell command to complete
 */
public class JavaShellExecute
{
    public static void main(String[] args) throws Exception {
        runShellCommand("open somefile.txt", true);
    }
 
    /**
     * The OPEN command on MacOSX causes the registered file handler to open a file.
     * The START command on Windows causes the registered file handler to open a file.
     *
     * Example param can include a path and file such as:
     * "open yourpath/somefile.txt"
     */
	public static void runShellCommand(String shellCommand, boolean printShellOutput) throws IOException, InterruptedException {
		Runtime runtime = Runtime.getRuntime() ;
		Process shellProcess = runtime.exec(shellCommand) ;
 
		//Only wait for if you need the external app to complete
		shellProcess.waitFor() ;
        
		//You can read the contents of the application's information it is writing to the console
		BufferedReader shellCommandReader = new BufferedReader( new InputStreamReader(shellProcess.getInputStream() ) ) ;
 
		String currentLine = null;
		while ( (currentLine = shellCommandReader.readLine() ) != null )
		{
			if (printShellOutput)
                System.out.println(currentLine);
		}
	}
}


Maybe someone else can do better.

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

3

Monday, August 5th 2013, 1:02pm

This is what I got So Far
---------------------------------------------

Source code

1
2
3
4
5
6
7
8
9
10
11
Dim FN as String,SN as String
Dim ShellExecute As java#lang#Runtime = Java#lang#Runtime.getRuntime
' *** This below is Dimmed for future error checking ***
Dim IOP As Java#lang#Process = Java#lang#Process
Dim IOE As java#io#BufferedReader = Java#io#BufferedReader


FN = "H:\Library\Filename.rtf"
SN = "start " & FN
Debug.Print SN
ShellExecute.exec(SN)

---------------------------------------------
I thought that first I would start with something a bit more sure, then when I got that to work introduce some unknowns and see if they might also function.
Things Like;
Dim ShellExecute As Runtime.getRuntime

Which appears to be a Jabaco implementation of the Java function

But I didn't get that far. The above code throws an error. It can't find the file

java.io.IOException: Cannot run program "start": CreateProcess error=2, The system cannot find the file specified

I tried to enclose the entire string in quotes;

Source code

1
2
3
4
FN = "H:\Library\Filename.rtf"
SN = Chr(34) & "start " & FN & Chr(34)
Debug.Print SN
ShellExecute.exec(SN)


Same error as above.

If I remove the "start " string;

Source code

1
2
3
4
FN = "H:\Library\Filename.rtf"
SN =  FN
Debug.Print SN
ShellExecute.exec(SN)


It also throws an error but now says;

java.io.IOException: Cannot run program "H:\Library\Filename.rtf": CreateProcess error=193, %1 is not a valid Win32 application

I have tried variations of using "open " even though the Java tutorial says to use that one for the Mac
No good.

I have used captalized "Open ", "Start ", "OPEN ", "START ", but seems to make no difference, evidently it is case insensetive.

I have verified it is indeed a legit Filename & Path,that it does exist, and it does have an associated Application.

I humbly call on your knowledge resources....
Can anyone help? At least someone out there can tell me if I'm doing something obviously wrong.

This post has been edited 1 times, last edit by "Perry" (Aug 5th 2013, 1:40pm)


theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

4

Tuesday, August 6th 2013, 1:01am

Your mentioned Java-program doing exactly the same like the Shell function in Jabaco.
The only difference is, that if printShellOutput is true, it outputs the text of the console.

But that is with the Shell-command possible, too:
[ http://www.jabaco.org/board/p3453-how-to…e-in-linux.html ]

You don't want to start a textfile direct with

Jabaco Source

1
Shell "notepad C:\textfile.txt"

An command like "start" exists only on the console. So if you want to start it with "start", then you have to write

Jabaco Source

1
Shell "cmd /c start C:\textfile.txt"


Greatings
theuserbl

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

5

Tuesday, August 6th 2013, 2:33pm

Thanks for that response.

A question then.
I don't have access to a MAC.
I assume that your implementation is for a MS OS
Is it implemented on a Mac the same way?
How about Linux and Unix OS?

Anybody try this on other operating systems?

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

6

Tuesday, August 6th 2013, 7:58pm

Thanks much. It works well in MS Windows and I understand from your thread it will work at least in Linux as well.
I placed it in a Jabaco wrapper

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Public Sub ShellExec(FN As String)
Dim p As java#lang#Process
Dim input As java#io#InputStream
Dim cdata As java#lang#Character
Dim data As Integer

p = Shell("cmd /c start " & FN)
input = p.getInputStream
data = input.read
While data <> -1
   cdata = Cast(data, java#lang#Character)      
   data = input.read
Wend
input.close
p.destroy

End Sub


I call it by:
ShellExec (Filename)
Thank you.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

7

Wednesday, August 7th 2013, 1:09am

A question then.
I don't have access to a MAC.
I assume that your implementation is for a MS OS
Right.


Quoted

Is it implemented on a Mac the same way?
How about Linux and Unix OS?
Anybody try this on other operating systems?

Thanks much. It works well in MS Windows and I understand from your thread it will work at least in Linux as well.


Java have the

Jabaco Source

1
Runtime.getRuntime().exec(shellCommand);
command. Or in Jabaco as short

Jabaco Source

1
Shell(shellCommand)


This method/function exists for every platform. But the programs on each platform are different.

Jabaco Source

1
cmd /c start textfile.txt

works only on Windows, because "cmd" exists only on Windows.
Linuix have instead the cmd the bash and MacOSX the csh.

I don't think, that you can call an stadard-program on that platforms.
Instead notepad.exe Linux have gedit on GNOME-based systems or kate or kwrite on KDE-based systems.
But it isn't like on Windows, where notepade.exe, calc.exe, taskmgr.exe, etc existing on every Windows-system. Possible there is a Linux-system, where no text-editor is installed.

So, if you want to be sure, that you can edit an textfile from every platform, then write your own texteditor in Java or using an external texteditor written for the JVM.

Greatings
theuserbl

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

8

Friday, August 9th 2013, 4:17pm

Quoted

So, if you want to be sure, that you can edit an textfile from every platform, then write your own texteditor in Java or using an external texteditor written for the JVM.

Well I did a search for a freeware RTF Editor for the JVM. I tried all I found and they were not satifactory.
Maybe you know of one that works well, but I suspicion there is a reason why these are so scarce.
I did see one that looked pretty good that would have cost a bit, but this program I'm making is offered to the public as Public Domain.
I would rather not depend on a paid-for program for support, let alone the fact that I can't distribute it.

I suspect the reason that they are so scarce is that they are no easy task to make, and in my searching, I found comments to the effect that Java lacks some in that department.

I need a way to print out formatted Barcode Labels on a label sheet (Avery Labels).
Not just the Barcode Alone however. It also needs a title line + other Identifying Lines in a person readable form.

Key here is formatted, that will keep it's placement and also will easily switch between fonts.

Maybe there are other formats that would do the job better. XML perhaps?

I know ... You are saying that if you need it ... do it yourself. Well that was a challenge.
While I may eventually do that .. My expertise isn't up to it .... Yet.

So .. bide my time .. collect Info... work on other things ....

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

9

Friday, August 9th 2013, 5:54pm

Hey there,

I did not look into it any further, but maybe this barcodegenerator alows additional text:
http://barcode4j.sourceforge.net/index.html

Also there are many VB implementations for barcodegenerators that might inspire a bit:
http://planetsourcecode.com/vb/scripts/B…riteria=barcode

Dani

Rate this thread
WoltLab Burning Board