Text fille help

Text fille help

Postby Jeff Barnes » Thu Apr 23, 2020 6: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: Select all  Expand view  RUN


{
    "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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Text fille help

Postby cnavarro » Thu Apr 23, 2020 6:33 pm

Look

Image

Code: Select all  Expand view  RUN

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

#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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Text fille help

Postby Jeff Barnes » Mon Apr 27, 2020 11:34 am

Excellent. Thanks :)
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Text fille help

Postby Jeff Barnes » Mon Apr 27, 2020 4:33 pm

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

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Text fille help

Postby nageswaragunupudi » Mon Apr 27, 2020 5:04 pm

Click on the + button
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Text fille help

Postby Jeff Barnes » Mon Apr 27, 2020 5: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 67 guests