Android Question text after comma elimination issue

67biscuits

Member
I have searched for a while, but find it difficult to ask the question in a way to elicit an appropriate response.
I have an edittext box that can have several lines of text including punctuation. However, if a comma is found in the text, anything after that is ignored and not saved.
eg: if I enter: "The small brown fox, despite lorem ipsum rhubarb rhubarb..." the recalled data would be only "The small brown fox,"
How does one bypass the comma delimitation factor?

cheers
 

67biscuits

Member
Following is the entire set of code and subs pertaining to the journal portion of the program. The sub cmdSaveJournal is where the text from the journal EditText view is captured to be saved.
So far my work around is to simply practice atrocious english with full stops, run-on sentences and incorrect punctuation. My English teachers are furious!! If the app is ever published, this work around option is not practical.

all the journal code:
Sub clvJournals_ItemClick (Index As Int, Value As Object)
    Dim lst As List = splitter(Value,",")
    putDate(lst.Get(0))
    lblClvIndex.Text = Index
    Dim k As String = lst.Get(2)
    seeEntry($"${k.trim} ✎ "$)
End Sub

Private Sub clvJournals_ItemLongClick (Index As Int, Value As Object)
    seeEntry(Value)
    If options.Get(5) Then
        journal.RemoveAt(Index)
        displayList(journal,clvJournals,0)
    End If
End Sub

Sub seeEntry(txt As String)
    txtJournalEntry.Text = txt
End Sub

Private Sub cmdNewJournalEntry_Click
    lblClvIndex.Text = -1
    txtJournalEntry.Text = ""
    TT= DateTime.now
    cmdDatePicker.text = DateTime.Date(TT)
End Sub

private Sub cmdSaveJournalEntry_Click
    entry = Array As Object(TT, DateTime.Time(DateTime.now), txtJournalEntry.Text)

    addEntry(entry, journal, clvJournals, 0, lblClvIndex.Text)

    resetTT
End Sub

Any insight will be appreciated. I'm sure I am looking at the solution, but my rose coloured spectacles are not working correctly.
I know you may ask...

addentry sub routine:
Sub addEntry(ent As List, lst As List, lv As CustomListView, dspIdx As Int, idxInList As Int)

    DateTime.DateFormat="E dd MMMM"

    If idxInList < 0 Then
        lst.Add(ent)
    Else
        lst.Set(idxInList,ent)
    End If
   
    displayList(lst,lv,dspIdx)

    saveAll  

End Sub

Looking further and logging results, I find it does save the data, it just is not displaying when recalled... still searching
 
Last edited:
Upvote 0

67biscuits

Member
If I put a comma in the text, it just gets saved as another element in a list that is then subsequently ignored as I am extracted .Get(nth) element to display. How do I save a .Text passage including commas as a string as opposed to a delimiter? (eg "I did this, then I did that. It was tedious, but i found the bug.")
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Any insight would be appreciated.

If you are looking for advice then here is my contribution. Don't use arrays or lists of objects of varying types as subroutine arguments . . .

B4X:
Sub addEntry(ent As List,  . . .,  . . .)

By using untyped arguments you are skirting much of the built-in error checking provided by the IDE and the compiler. You will surely make simple mistakes that will be undetected because of this and I suspect that is what is happening. I imagine that you are using arrays because it allows you to associate together related variables into one structure. Yes - that is a good plan, but you are doing it the wrong way. You should be using a Type structure . . .

B4X:
Type journalEntry(date as long, header as string, body as string, serialNum as int, etc as Boolean)

. . .

Sub processEntry(ent as journalEntry)

. . .

. . .

I am fairly sure that if you do this your problem with commas will simply disappear. But in any case your code will be much more structured and readable and to some extent self-documenting. You will appreciate that if you come back to adapt your code some time in the future.
 
Upvote 0

67biscuits

Member
Hey Dean, Thanks, what you say makes sense. Essentially the 'Type' in this case would be the 'list' of data created from one journal entry,(date, time, text of journal etc) then then passed to the sub ProcessEntry for processing, eg:
'declared in sub globals, yes?
Type entry = (idTag as String, TT as Long, TimeNow as Long, journal as String)

How do i assign the values to the Type and send for processing?
I have to go to work for a few hours but till read up more when I return. There is video re: types, which I will also watch. I've used Types in the past, so it should be a doddle once I put all the jigsaw bits together.

cheers again

Charley
 
Upvote 0

67biscuits

Member
So I plugged in the Type method and made it it work, but I quickly discovered the argument against Types. I have 4 more Types to make that have different information and more importantly different amounts of variables withing the Type. I now have five Types that cannot use the same addEntry sub. The journal entry, for example, has 3 data; the hours entry has 4 data; the materials entry has potentially 7 data. So, I can generic-ize the Type with an identifier & common data like date and time, and say, 10 variables as Objects named myObjOne through myObjTen to cover the varying other data that might fall into the Type. That could be handled by a Select Case, but I find most of the time that a Select Case doesn't really mitigate the DRY code factor and that I would be better off eliminating the addEntry sub, and handling the process individually under the saveEntry button.
So back to the drawing board. I will add the entries on an individual basis executed by the saveEntry button, and therefore not be required to create the Type afterall.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…