FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Text fille help
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Text fille help
Posted: Thu Apr 23, 2020 06:20 PM
I have a text file created by another program (it's a json file)
I need to find a way to allow a user to delete an entry from the text file via a user interface.

Can anyone point me in the right direction. The issue I'm having is how to locate the specific entry and remove it.

Here is what the file looks like:


Code (fw): Select all Collapse
{
    "items": [
        {
            "name": "color 1",
            "image": "",
            "day": "1",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "1",
            "location": "",
            "description": ""
        },
        {
            "name": "color 2",
            "image": "",
            "day": "2",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "2",
            "location": "",
            "description": ""
        },
        {
            "name": "color 3",
            "image": "",
            "day": "3",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "3",
            "location": "",
            "description": ""
        },
        {
            "name": "color 4",
            "image": "",
            "day": "4",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "4",
            "location": "",
            "description": ""
        },
        {
            "name": "color 5",
            "image": "",
            "day": "5",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "5",
            "location": "",
            "description": ""
        },
        {
            "name": "color 6",
            "image": "",
            "day": "6",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "6",
            "location": "",
            "description": ""
        },
        {
            "name": "color 7",
            "image": "",
            "day": "7",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "7",
            "location": "",
            "description": ""
        },
        {
            "name": "color 8",
            "image": "",
            "day": "8",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "8",
            "location": "",
            "description": ""
        },
        {
            "name": "color 9",
            "image": "",
            "day": "9",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "9",
            "location": "",
            "description": ""
        },
        {
            "name": "color 10",
            "image": "",
            "day": "10",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "10",
            "location": "",
            "description": ""
        },

        {
            "name": "xxxRobertoRoberto Tapia",
            "image": "events/images/roberto_tapia.jpg",
            "day": "8",
            "month": "3",
            "year": "2020",
            "time": "8:00 pm",
            "duration": "4",
            "color": "4",
            "location": "",
            "description": ""
        } 
    ]
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Text fille help
Posted: Thu Apr 23, 2020 06:33 PM
Look



Code (fw): Select all Collapse
//----------------------------------------------------------------------------//
//
//----------------------------------------------------------------------------//

#include "Fivewin.ch"

//----------------------------------------------------------------------------//

Function Main()

   local cText
   local hHash  := { => }
   TEXT INTO cText
{
    "items": [
        {
            "name": "color 1",
            "image": "",
            "day": "1",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "1",
            "location": "",
            "description": ""
        },
        {
            "name": "color 2",
            "image": "",
            "day": "2",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "2",
            "location": "",
            "description": ""
        },
        {
            "name": "color 3",
            "image": "",
            "day": "3",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "3",
            "location": "",
            "description": ""
        },
        {
            "name": "color 4",
            "image": "",
            "day": "4",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "4",
            "location": "",
            "description": ""
        },
        {
            "name": "color 5",
            "image": "",
            "day": "5",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "5",
            "location": "",
            "description": ""
        },
        {
            "name": "color 6",
            "image": "",
            "day": "6",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "6",
            "location": "",
            "description": ""
        },
        {
            "name": "color 7",
            "image": "",
            "day": "7",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "7",
            "location": "",
            "description": ""
        },
        {
            "name": "color 8",
            "image": "",
            "day": "8",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "8",
            "location": "",
            "description": ""
        },
        {
            "name": "color 9",
            "image": "",
            "day": "9",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "9",
            "location": "",
            "description": ""
        },
        {
            "name": "color 10",
            "image": "",
            "day": "10",
            "month": "4",
            "year": "2020",
            "time": "",
            "duration": "1",
            "color": "10",
            "location": "",
            "description": ""
        },

        {
            "name": "xxxRobertoRoberto Tapia",
            "image": "events/images/roberto_tapia.jpg",
            "day": "8",
            "month": "3",
            "year": "2020",
            "time": "8:00 pm",
            "duration": "4",
            "color": "4",
            "location": "",
            "description": ""
        }
    ]
}
   ENDTEXT

   hb_JsonDecode( cText, @hHash )
   XBrowse( hHash[ "items" ] )
   
Return nil

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Text fille help
Posted: Mon Apr 27, 2020 11:34 AM

Excellent. Thanks :)

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Text fille help
Posted: Mon Apr 27, 2020 04:33 PM

How would I add a new entry ?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Text fille help
Posted: Mon Apr 27, 2020 05:04 PM

Click on the + button

Regards



G. N. Rao.

Hyderabad, India
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Text fille help
Posted: Mon Apr 27, 2020 05:10 PM

Sorry, I should have provided more info....
(never worked with json or hash before so please forgive any dumb questions)

I am reading a json file into a text var (cText) and working with the data in the background.
I'm not displaying the data in a browse.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)

Continue the discussion