Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Breakapart question

Status
Not open for further replies.

WelshyWizard

IS-IT--Management
Apr 23, 2006
89
GB
Hi all,

I've the following code:

Code:
tcSplit.open("Temp Import.db")
tcSplit.edit()

scan tcSplit:

strSptGdr = tcSplit."USER1"   	  ;// Look in this field for Gdr No's
strSptGdr.breakApart(arSplit, "_") ;// The underscore will split the Gdr No's
;ar.view()

if tcSplit."USER2" = "SPBF" OR tcSplit."USER2" = "SPWEB" OR tcSplit."USER2" = "SPTF"
OR tcSplit."USER2" = "BR" OR tcSplit."USER2" = "BP" then

tcSplit."Gdr1" = arSplit[1] ;// Place the first Gdr number in field Gdr1 (before the underscore)
tcSplit."Gdr2" = arSplit[2] ;// Place the second Gdr number in field Gdr2 (after the underscore)

tcSplit.unlockRecord()

endif

endscan

tcSplit.endedit()
tcSplit.close()

This code basically splits a string when it finds an underscore '_'.
I want the code skip if it doesn't find an underscore. At the moment it just crashes... Any ideas?

Cheers

Today is the tomorrow you worried about yesterday - and all is well.....
 
You need to make sure the array size = 2

Code:
if arSplit.size() = 2 then
    if tcSplit."USER2" = "SPBF" OR tcSplit."USER2" = "SPWEB"  OR tcSplit."USER2" = "SPTF"
    OR tcSplit."USER2" = "BR" OR tcSplit."USER2" = "BP" then

    tcSplit."Gdr1" = arSplit[1] ;// Place the first Gdr number in field Gdr1 (before the underscore)
    tcSplit."Gdr2" = arSplit[2] ;// Place the second Gdr number in field Gdr2 (after the underscore)

    tcSplit.unlockRecord()
endif


Hope this helps
Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top