Solved

SETTING PROGRAM VARIABLES FIXED WHILE CHAINING PROGRAMS

Posted on 2004-09-22
7
191 Views
Last Modified: 2010-04-17
I have a first module wich lets the user login, he makes choice wich printer wants to use while running etc.
Then I would like to run in this first module (is kind off menu choices) a function wich
opens a file wich contains:  datapath for all ledgerdata, datapath for all faxes, datapath for orders, etc. Then this variables I want to have available in any program chained so I only have to do maintence in first module.
Chaining example:

Private sub Invoices_click()
   Shell("k:\vbaua\invoices.exe", vbNormalFocus)
' I would like to have at chaining allready:   Shell (programs & "invoices.exe",vbNormalFocus)
' and take all varibles like username with me to invoices.exe
end Sub
0
Comment
Question by:BIAPRO
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Expert Comment

by:aravindtj
ID: 12124509
Use a module G, to store the variable which you need to share the variable to all the other modules.
Start the application throgh that module G. [no need].
Set the value of that variable in that module G. So, you can access them in all the modules.
0
 
LVL 3

Expert Comment

by:Validor
ID: 12124860
You actually have two EXEs and want to share variables between them.  Is that right?

It is my recommendation that you not do this.  Shelling is bad practice anyway.  

You should instead merge the two into a single .EXE.  If this is not an option, then the only way I can think of to do this is to pass the variables as a dataset through some medium such as a temporary file, MQ, etc.  It can't very well be a "live" means such as sockets, named pipes, etc. because the shelled program may not be ready when you think it is, and the program that launches it doesn't return control to you until the process ends (and the called EXE closes).  The only way I can see this happening is if you first start another thread before you shell, and have that thread answer communication with the shelled EXE.  This is not a pretty solution.
0
 

Author Comment

by:BIAPRO
ID: 12125453
The reason I do shell (I think , because I'm a old dos-programmer switching to VB6),
that programs I'm converting are big , realy big.
They have different functions, so what we did in dos was having a main.exe and in that
main.exe users 'chained' instead of 'shellling' to what ever they had to do.
I could not find a 'chain'  function in VB thats why I do shell.
I do protect them from not more then one shell at the time, so always return to calling
main-module.exe
If there would be a better solution, I will be happy to learn

Regards Jack
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12126170
If you have the source code for the apps then modify them so they accept command line parameters.  Then you can pass the values to the next app in your Shell() statement.

Idle_Mind
0
 
LVL 3

Expert Comment

by:Validor
ID: 12126436
That's how it goes sometimes.  The called process is also a windows application, is it not?  If so, you could store a value in the registry telling it where the common medium is (be sure to watch for multiple instances of your app), or better yet, as Idle Mind pointed out, a command-line parameter.

If there is a lot of data to pass or if it is complex, my recommendation for this medium is an XML document.

If it's simple data, you could just pass the values instead ofa descriptor of the medium.
0
 

Author Comment

by:BIAPRO
ID: 12126687
Yes I have all source because we rewrite the dos-stuff to Vb-stuff, I think that what Idle_Mind suggest would solve it right?, because 1st. main.exe is small can open in main.exe 'a parameter'  file for wich I can make a maintenance module if changes needed.
Then a Case situation were to goto and what parameters to 'chain' are,
Could you please give (short) syntax what a 'call' woul look like, and the 'chained' module has as syntax to extract parameter.
e.g.   Username$ = "jack":  Password$ = "OK"  : datapath$ ="I:\data"
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12128597
Here is how you would Shell() the application:

    Private Sub Command1_Click()
        Dim userName As String
        Dim passwrod As String
        Dim dataPath As String
        Dim cmdLine As String
   
        userName = "Jack"
        password = "OK"
        dataPath = "I:\data"
   
        cmdLine = "c:\project1.exe " & userName & " " & password & " " & dataPath
        Shell cmdLine, vbNormalFocus
    End Sub

Here is how you would process those command line parameters in your application:

    Private userName As String
    Private password As String
    Private dataPath As String
 
    Private Sub Form_Load()
        Dim parameter As Variant
   
        parameter = Split(Command())
        If UBound(parameter) = 2 Then
            userName = parameter(0)
            password = parameter(1)
            dataPath = parameter(2)
       
            Dim msg As String
            msg = "userName = " & userName & vbCrLf & _
                "password = " & password & vbCrLf & _
                "dataPath = " & dataPath
            MsgBox msg
        Else
            MsgBox "Invalid Number of Parameters"
        End If
    End Sub

For this to work, there cannot be any spaces in your userName, password or dataPath.  If you think there may be spaces in your dataPath, then convert it to a short file name.  Let me know if you need help with that part.

Regards,

Idle_Mind
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now