cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Recipe delete in WinStudio

Recipe delete in WinStudio

plaszlo
New Poster

Hi, 

I have a HMI project in WinStudio and I would like to use Recipes. The base is working well, I can save data into the recipe, and I can display a list of the saved recipes, but I can't delet in the right way.. 

Basically I store about 50 parameters in the recipe file (.DAT), and save the list of the reciepes in a txt file, to display and save the list I use Grids and probably this is the main problem what I can't solve. The grid save the txt with comma delimiters and to indicate the end of line it place two comma at the end of the row. When i try to delet the data, this two comma stay in the file and ruin my list. 

In the list I store 4 strign variable for each recipes (ID, name, user, comment), this happening in the following way: 
$InsertedValues=$ID & "," & $name & "," & $user & "," & $comment  

The InsertedValuse string is the input of the grid, which saves the txt file, and an the other grid read this txt. 

My problem is that I can not delet the full line of the txt, I can only make the variables "empty" and insert in to the selected row. 
Is there any way to delete a line from the txt file ? Can you suggest any other way, make my recipe list working? 

Thank you in advance! 

3 REPLIES 3

HmiGuide
Community Moderator
Community Moderator
  • What is your target Operating System? A CE based system or Windows 10,11,...
  • How do you add the new entries into the file? e.g. With WinStudio file function, Features of the grid, VB Script file functions

 

The target OS is Windows 11. 
I add the new entries into the file with the features of the grid. 

HmiGuide
Community Moderator
Community Moderator

To use a grid (table) as file open box, do the following steps:

  • Use only one grid to display the csv file with read only mode
  • Use file handling to edit the csv file (add and remove a row)

Use the grid to display the csv file with read only mode
To avoid access problems (=file could not be written, when it is displayed in the grid) activate option “Read only”

HmiGuide_0-1718609528466.png

Use file handling to edit the csv file (add and remove a row)
You can use WinStudio functions or VB script functions to read and write the csv file.

  • WinStudio functions are available on CE and PC operating systems
    FileReadFields(), FileWriteFields()
  • For VB script functions find many examples in internet, but not working on CE operating systems

To add a row append it to the end of the file.
You must ensure, that the filed separator, which you have defined for the CSV file is not used in any variable you save to the CSV file.

To delete a row:

  • Read all rows of the file into a VB script array variable
  • Delete the csv file
  • Save all data stored int VB script array variable, but not the one you want to delete
  • Repaint the grid, to display the changed csv file
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist