Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

bat command

hello,every teacher.recently,a customer give me advise for a software change(two versions labview and vb6.0) .something like below:
 1) All unit is to generate 1 .txt file.
2) All the script is to run a .bat command after saving the data to a
file to a local computer. This .bat command will transfer the file from
the local computer to the server.
3) All data file are to be saved to an specified folder in all local
computer. In this way, the server will know where to retrieve the files
from.
 
i don't know anything about .bat command ,especially in labview and VB6.0? is there anything I need any more from customer(example:path to bat)?
how can i achieve customer requset(for 2)?
thank you.
 
 
0 Kudos
Message 1 of 9
(9,607 Views)
A batch job in Windows/DOS world is one of scripting technique to process one or more jobs sequentially.  A batch file is exactly a text file whose file extension is .BAT.  The .BAT file can be read by cmd.exe (in WinNT/2k/XP) or by command.com (Win9x) as a data file, but the contents of .BAT work as script as if you interactively processed on Command Prompt.
 
Running a .BAT file is meaning that you are running cmd.exe (or command.com) with feeding the BAT file as its script scenario.  As default, .BAT extension is already associated with cmd.exe (or command.com).
0 Kudos
Message 2 of 9
(9,599 Views)
The batch file will execute without showing itself on the screen and exit after its done.,how  i can do in labview and VB?thank you
0 Kudos
Message 3 of 9
(9,587 Views)
In VB6, you can use Shell() function to run a .BAT file.  This automatically launches cmd.exe. 
 
In LabVIEW, it looks like "System Exec" function does it.  According to HELP, this VI directly accepts a .BAT file to launch a batch job.  Sorry but I don't know more than this because I am not much familiar with LabVIEW.
0 Kudos
Message 4 of 9
(9,580 Views)
thank you.Makoto ,another question need your help.in my computer,a txt file exist, i know the file name and the path,I want to write data to a centain row ,how to do(vb6.0)? example: i want to write "123456"to 7th row in txt file.
0 Kudos
Message 5 of 9
(9,565 Views)

In many cases, a VB6 app writes text files in a traditional BASIC way using OPEN/PRINT/INPUT/CLOSE functions.  However, this approach is ASCII stream based, therefore you can't write a text partially into a specific line.  (There is no method to control the offset in bytes or lines for PRINT/INPUT actions. )  To solve this, your app must buffer all the line contents before actual writing, then write all the lines at once.

For example, if your VB6 app wants to write a 1000 line text file, your app shall keep a string array such as
Dim astrLines(1 to 1000) As String

Then fill or replace each line as you want.  When writing them into a text file, you can use traditional PRINT function repeating all the lines (1 to 1000) everytime you write.

Dim astrLines(1 To 1000) As String
Dim i As Long
...
astrLines(7) = "123456"
...
Open "C:\xxx\xxx.txt" For Output As #1
For i = 1 To 1000
  Print astrLines(i)
Next i
Close #1

There are also other way to write/read specific part partially in a file -- Win32 standard API CreateFile/WriteFile/ReadFile/CloseHandle.  However, it is not intended for text file, where each line length is different depending on the contents.  These Win32 file API requires byte-offset and length info when you write/read partially.

 

0 Kudos
Message 6 of 9
(9,552 Views)
in MY vb programme,I WRITE:
Shell(pathtobat,vbHide) it can't pass complie.but if I write :
call Shell(pathtobat,vbHide)
it may be ok ,why?
 
 
note:pathtobat is string variable,the value is path to bat file
thankyou
0 Kudos
Message 7 of 9
(9,507 Views)
> in MY vb programme,I WRITE:
> Shell(pathtobat,vbHide) it can't pass complie.but if I write :
> call Shell(pathtobat,vbHide)
> it may be ok ,why?

It is a very basic syntax issue of VB6. In VB6, parentheses for enclosing the parameters can only be used under one of the 3 cases below:

1) invoke a FUNCTION and you explicitly receive its return
   ex, r = MyFunc(x,y)

2) invoke a FUNCTION with CALL keyword without receiving its return
   ex, Call MyFunc(x,y)

3) invoke a PROCEDURE with CALL keyword
   ex, Call MyProc(x,y)

When you do not explicitly receive the FUNCTION return, or when you can not receive the return due to PROCEDURE (no return type), you only need one of the 2 ways below:

a) invoke a FUNCTION or PROCEDURE using CALL keyword and parentheses
   ex, Call MyFunc(x,y), or Call MyProc(x,y)

b) invoke a FUNCTION or PROCEDURE without using parentheses
   ex, MyFunc x,y, or MyProc x,y

 

0 Kudos
Message 8 of 9
(9,500 Views)
thank you alaways help.
0 Kudos
Message 9 of 9
(9,482 Views)