You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 21st, 2007, 10:07 AM   #1
briana banks
Member
United States

briana banks is offline
 
Join Date: Jul 2005
Posts: 242
Delete recipe in rsview file using command button??

Hi All

Using RSview se 3.2
is it posible to delete recipe file using command button vba??


Thanx
  Reply With Quote
Old January 21st, 2007, 07:45 PM   #2
Lancie1
Lifetime Supporting Member
United States

Lancie1 is offline
 
Lancie1's Avatar
 
Join Date: Jul 2003
Location: Alabama
Posts: 9,999
Briana,
I assume that you are trying to delete the ASCII tecxt file that contains a RSView Recipe.

It is possible to write a Visual Basic program, or a Macro (list of Commands stored as a text file), that is called by a command button, that will delete a Recipe file. It would also be possible to change the values in a Recipe file, say to all blanks, or 0's, so that the file frame and title is still in place.
  Reply With Quote
Old January 22nd, 2007, 03:41 AM   #3
briana banks
Member
United States

briana banks is offline
 
Join Date: Jul 2005
Posts: 242
Hi


How can i know the path to "..\RCP" ?

Thanx
  Reply With Quote
Old January 22nd, 2007, 09:42 AM   #4
TConnolly
Lifetime Supporting Member
United States

TConnolly is offline
 
TConnolly's Avatar
 
Join Date: Apr 2005
Location: Salt Lake City
Posts: 6,151
I have completely ditched the RSView Recipe (quite frankly it sucks) and written my own. I make WIN API calls to open a standard Windows File browser like you see in other applications for file operations. I include references (Menu->Tools->References) for Microsoft forms, Microsoft Office Object library, Common language Runtime Execution engine, and Common Language Runtime Library. You can then navigate to wherever your want, cut, copy, paste, rename and delete files.

Here is the VBA code to open a windows file browser. Place the code in a module called FileBrowser. My recipes are written in a format that allows me to open and edit them offline in Excel as well as being able to be loaded into the PLC and edited from within RSView. Unfortunately, I can't post that part of the code because it would divulge proprietary recipe structure. In the Rockwell KB however there is an old technote about how to parse an RCP file to load a recipe to tags from VB. If you do want to make your own recipe app, I suggest you start there. Hopefully you will find this helpful.


'************************************************* ******
'Calls win API procedures to open a common dialog box
'to get the name of a file to 'open or save to.
'************************************************* ******
'type definition the data structure for open/save file dialogs
Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
'declare the functions in the common dialog dll
Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
Global Const ahtOFN_READONLY = &H1
Global Const ahtOFN_OVERWRITEPROMPT = &H2
Global Const ahtOFN_HIDEREADONLY = &H4
Global Const ahtOFN_NOCHANGEDIR = &H8
Global Const ahtOFN_SHOWHELP = &H10
Global Const ahtOFN_ENABLEHOOK = &H20
Global Const ahtOFN_ENABLETEMPLATE = &H40
Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80
Global Const ahtOFN_NOVALIDATE = &H100
Global Const ahtOFN_ALLOWMULTISELECT = &H200
Global Const ahtOFN_EXTENSIONDIFFERENT = &H400
Global Const ahtOFN_PATHMUSTEXIST = &H800
Global Const ahtOFN_FILEMUSTEXIST = &H1000
Global Const ahtOFN_CREATEPROMPT = &H2000
Global Const ahtOFN_SHAREAWARE = &H4000
Global Const ahtOFN_NOREADONLYRETURN = &H8000
Global Const ahtOFN_NOTESTFILECREATE = &H10000
Global Const ahtOFN_NONETWORKBUTTON = &H20000
Global Const ahtOFN_NOLONGNAMES = &H40000
Global Const ahtOFN_EXPLORER = &H80000
Global Const ahtOFN_NODEREFERENCELINKS = &H100000
Global Const ahtOFN_LONGNAMES = &H200000
Private Const conDefaultDir = "C:\1400 Ton M3 Press\RCP" 'Was "My Documents"
Private Const conOpenDialogTitle = "Open MegaDiamond Press Recipe File"
Private Const conSaveDialogTitle = "Save MegaDiamond Press Recipe File"
Function testit()

MsgBox "You selected: " & GetOpenRecipeFileName
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
Function GetOpenRecipeFileName() As Variant ' Returns the file name of a recipe to open or null if canceled.
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
' Sef flags that the chosen file must already exist, don't change directories when you're done, dont display the read-only box.
lngFlags = ahtOFN_FILEMUSTEXIST Or ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR

'initialize the filter string for Megadiamond cubic pres files and all files
strFilter = ""
strFilter = ahtAddFilterItem(strFilter, "MegaDiamond Cubic Press Files (*.mpf)", "*.MPF")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Now actually call to get the file name.
varFileName = ahtCommonFileOpenSave(OpenFile:=True, InitialDir:=conDefaultDir, Filter:=strFilter, Flags:=lngFlags, DialogTitle:=conOpenDialogTitle)
If Not IsNull(varFileName) Then
varFileName = TrimNull(varFileName)
End If
GetOpenRecipeFileName = varFileName
End Function
Function GetSaveRecipeFileName() As Variant ' Returns the file name of a recipe to open or null if canceled.
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
' Sef flags that the chosen file must already exist, don't change directories when you're done, dont display the read-only box.
lngFlags = ahtOFN_FILEMUSTEXIST Or ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR

'initialize the filter string for Megadiamond cubic pres files and all files
strFilter = ""
strFilter = ahtAddFilterItem(strFilter, "MegaDiamond Cubic Press Files (*.mpf)", "*.MPF")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

' Now actually call to get the file name.
varFileName = ahtCommonFileOpenSave(OpenFile:=False, InitialDir:=conDefaultDir, Filter:=strFilter, Flags:=lngFlags, DialogTitle:=conSaveDialogTitle)
If Not IsNull(varFileName) Then
varFileName = TrimNull(varFileName)
End If
GetSaveRecipeFileName = varFileName
End Function
Function ahtCommonFileOpenSave( _
Optional ByRef Flags As Variant, _
Optional ByVal InitialDir As Variant, _
Optional ByVal Filter As Variant, _
Optional ByVal FilterIndex As Variant, _
Optional ByVal DefaultExt As Variant, _
Optional ByVal FileName As Variant, _
Optional ByVal DialogTitle As Variant, _
Optional ByVal hwnd As Variant, _
Optional ByVal OpenFile As Variant) As Variant
'All parameters are optional.
' In:
' Flags: one or more of the ahtOFN_* constants, OR'd together.
' InitialDir: the directory in which to first look
' Filter: a set of file filters, set up by calling
' AddFilterItem. See examples.
' FilterIndex: 1-based integer indicating which filter
' set to use, by default (1 if unspecified)
' DefaultExt: Extension to use if the user doesn't enter one.
' Only useful on file saves.
' FileName: Default value for the file name text box.
' DialogTitle: Title for the dialog.
' hWnd: parent window handle
' OpenFile: Boolean(True=Open File/False=Save As)
' Out:
' Return Value: Either Null or the selected filename
Dim OFN As tagOPENFILENAME
Dim strFileName As String
Dim strFileTitle As String
Dim fResult As Boolean
' Give the dialog a caption title.
If IsMissing(InitialDir) Then InitialDir = CurDir
If IsMissing(Filter) Then Filter = ""
If IsMissing(FilterIndex) Then FilterIndex = 1
If IsMissing(Flags) Then Flags = 0&
If IsMissing(DefaultExt) Then DefaultExt = ""
If IsMissing(FileName) Then FileName = ""
If IsMissing(DialogTitle) Then DialogTitle = ""
If IsMissing(hwnd) Then hwnd = Application.WindowHandle
If IsMissing(OpenFile) Then OpenFile = True
' Allocate string space for the returned strings.
strFileName = Left(FileName & String(256, 0), 256)
strFileTitle = String(256, 0)
' Set up the data structure before you call the function
With OFN
.lStructSize = Len(OFN)
.hwndOwner = hwnd
.strFilter = Filter
.nFilterIndex = FilterIndex
.strFile = strFileName
.nMaxFile = Len(strFileName)
.strFileTitle = strFileTitle
.nMaxFileTitle = Len(strFileTitle)
.strTitle = DialogTitle
.Flags = Flags
.strDefExt = DefaultExt
.strInitialDir = InitialDir
' Didn't think most people would want to deal with
' these options.
.hInstance = 0
'.strCustomFilter = ""
'.nMaxCustFilter = 0
.lpfnHook = 0
'New for NT 4.0
.strCustomFilter = String(255, 0)
.nMaxCustFilter = 255
End With
' This will pass the desired data structure to the
' Windows API, which will in turn it uses to display
' the Open/Save As Dialog.
If OpenFile Then
fResult = aht_apiGetOpenFileName(OFN)
Else
fResult = aht_apiGetSaveFileName(OFN)
End If
' The function call filled in the strFileTitle member
' of the structure. You'll have to write special code
' to retrieve that if you're interested.
If fResult Then
' You might care to check the Flags member of the
' structure to get information about the chosen file.
' In this example, if you bothered to pass in a
' value for Flags, we'll fill it in with the outgoing
' Flags value.
If Not IsMissing(Flags) Then Flags = OFN.Flags
ahtCommonFileOpenSave = TrimNull(OFN.strFile)
Else
ahtCommonFileOpenSave = vbNullString
End If
End Function
Function ahtAddFilterItem(strFilter As String, strDescription As String, Optional varItem As Variant) As String
'Build the file filter string, appends to the existing filter string as filter items are added. String should be emptied before calling the first time
If IsMissing(varItem) Then varItem = "*.*"
ahtAddFilterItem = strFilter & strDescription & vbNullChar & varItem & vbNullChar
End Function
Private Function TrimNull(ByVal strItem As String) As String 'Trim the null characters of a string.
Dim intPos As Integer
intPos = InStr(strItem, vbNullChar)
If intPos > 0 Then
TrimNull = Left(strItem, intPos - 1)
Else
TrimNull = strItem
End If
End Function

Last edited by TConnolly; January 22nd, 2007 at 09:44 AM.
  Reply With Quote
Old January 25th, 2007, 01:53 PM   #5
briana banks
Member
United States

briana banks is offline
 
Join Date: Jul 2005
Posts: 242
Thank you.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
RSView Studio for ME - creating runtime file pimpim32 LIVE PLC Questions And Answers 14 November 13th, 2014 12:23 PM
recipe files couldnot be deleted in runtime file in AB PanelViewPlus prakashn LIVE PLC Questions And Answers 3 April 3rd, 2006 11:08 PM
How to edit RSVIew SE alarm log file?? briana banks LIVE PLC Questions And Answers 2 March 2nd, 2006 11:11 AM
Recipes and RSView32 poiuy LIVE PLC Questions And Answers 7 October 1st, 2005 02:33 PM
Data Tables bosshen LIVE PLC Questions And Answers 5 April 28th, 2003 06:30 PM


All times are GMT -5. The time now is 12:14 AM.


.