Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Unanswered: Delete Specific Array[] Assignments

    I have this in Paradox Ver.7 table. (Over 5,000 records)

    NEWPORT COAST STATE CA
    OCEANSIDE STATE CA
    CORONA DEL MAR STATE CA
    LA JOLLA STA

    I need to delete everything from the word, or partial word "STATE" and all that is to the right of it.

    I can parse this out in an Array[] but how can I delete specific array assignments?

    Thanks in Advance.

    Rick (RickinNpt@cs.com

  2. #2
    Join Date
    Oct 2003
    Posts
    107
    I would probably use breakapart() to get my array, then test each element in a loop. Count the iterations and only put back the number of elements up to and including "sta" or "state" in an assignment back to the field value.

  3. #3
    Join Date
    Mar 2004
    Location
    California
    Posts
    502
    Originally posted by lmckelvy
    I would probably use breakapart() to get my array, then test each element in a loop. Count the iterations and only put back the number of elements up to and including "sta" or "state" in an assignment back to the field value.
    How would I test each element in Breakapart() AND in Array[] ?

    Thanks . . . Rick

  4. #4
    Join Date
    Oct 2003
    Posts
    107
    This is an example of how to apply it. Just stick it in a script to demo it. You would want to modify this to place it inside a scan loop in order to assign the Addy variable..

    Code:
    var 
      myAr Array[] String ; Must be resizable
      Addy String
      numEl longint
      cntr  longint
      redo  longint	
    endvar 
    
    redo = 1
    
    Addy = "NEWPORT COAST STATE CA"
    
    Addy.breakApart(myAr)
    
    numEl = myAr.size()
    
    view(myAr)
    for cntr from 1 to numEl
    
    	if myAr[cntr].subStr(1,3) = "STA"
    		then 	Addy = ""
    				while redo <= cntr
    					Addy = Addy+myAr[redo]
    					if redo <> cntr then Addy = Addy+" " endif
    					redo = redo+1
    				endwhile
    				quitloop
    	endif					
    				
    
    
    
    
    endfor
    
    Addy.view()
    I'll be out of town for a few days, but will try to answer any questions when I get back.

  5. #5
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Thanks . . .

    I'll try this out tonight and let you know what I come up with.

    Thanks again . . . Rick

  6. #6
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Here is script with comments!

    method run(var eventInfo Event)
    Var
    tc TCursor
    myar Array[] String ; Must be resizable
    Addy String
    Cntr longint
    Numel longint
    Redo longint
    SDRoster table
    endVar
    ;-----------------------------------------------------------------
    addAlias("MYDIR","Standard","D:\\Pdoxwin7\\SanDieg o\\SDRoster.db")
    ;-----------------------------------------------------------------
    if Not tc.open("D:\\Pdoxwin7\\SanDiego\\SDRoster.db") then ;table name
    errorShow()
    return
    endif
    tc.edit()
    scan tc:
    redo = 1
    Addy=tc."City"
    Addy.breakapart(myar)
    numel = myar.size()

    for cntr from 1 to numel

    if myar[cntr].substr(1,3) = "STA.." ;keeps returning to the redo = 1 line???
    then addy = "" {Also subsrt (1,3) can be anywhere from
    1 to 6}
    While redo <=cntr
    addy = addy+myar[redo]
    if redo<>cntr then addy = addy+""
    endIf

    redo=redo+1
    Message("Processing Record No. ", tc.recno())
    If tc.eot() then
    Message("Reached the end of the table Rick...")
    endIf

    endWhile
    quitloop
    endIf
    endFor
    endScan
    endMethod
    ;==============================(eND)============== =================

  7. #7
    Join Date
    Oct 2003
    Posts
    107
    Hey Rick,

    I got back and looked at your post. I have modified your script as follows and sent it to you in an email. I'm posting here in case anyone else is interested in the solution.

    The problems were:

    > if myar[cntr].substr(1,3) = "STA.." ;keeps returning to the redo = 1
    > line???

    This was caused by your addition of the ".."

    The original line simply looked at the first three characters of the current array element. If they were "STA" then it was assumed that the word was STA or STATE.


    > {Also subsrt (1,3) can be anywhere from 1 to 6}

    Not sure what you mean by this, maybe I answered it above.


    > if redo<>cntr then addy = addy+"" endIf

    There has to be a space between the quotes.



    > If tc.eot() then Message("Reached the end of the table Rick...") endIf

    I remarked this out. If needed, you can just stick:

    Message("Reached the end of the table Rick...")

    after the endScan. The scan stops automatically at the end of the table when the last record is reached and any code within the scan loop has been executed.


    This will modify every record so that everything to the right of STA or STATE will be gone.

    Cheers,

    Mac

  8. #8
    Join Date
    Jan 2004
    Location
    amsterdam
    Posts
    31
    I don't understand why you have to program this when there is an easy solution to it. Export to delimited ascii into a wordprocessor, with a macro remove from "sta" to the end of line and import back into paradox. This will cost you only 1 minute.

  9. #9
    Join Date
    Oct 2003
    Posts
    107
    > I don't understand why you have to program this


    I don't know if it is to be a one-shot deal or not. Certainly it would have been simpler to do it the way you describe - provided one was well versed in creating word processing macros that picked words out of the middle of a line. However, if the process needs to be automated then the less software involved the better, in my opinion.

    Besides, it was good practice

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •