Text fille help

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Text fille help

Post by Jeff Barnes »

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: Select all


{
    "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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Text fille help

Post by cnavarro »

Look

Image

Code: Select all

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

#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

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

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Text fille help

Post by Jeff Barnes »

Excellent. Thanks :)
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Text fille help

Post by Jeff Barnes »

How would I add a new entry ?
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Text fille help

Post by nageswaragunupudi »

Click on the + button
Regards

G. N. Rao.
Hyderabad, India
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Text fille help

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
Post Reply