I.T. Discussion Community!
-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
-Collapse +Expand Paradox To/From
To/FromCODEGuides
-Collapse +Expand Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardObjectPAL Topic   Print This     

Code to delete record's last character

Code to delete record's last character in ObjectPAL topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: character   Code delete   Code delete record   s last  
Lothar.K
-- --
Rank: Cadet 4th Year

Hello,

This would seem pretty simple, but...

I have some code that generates a CSV file that I then export to my phone.

I need to tweak the code so that it looks at the last character of each record, and then deletes that character if it is a comma.

Might you point me in the right direction to do that? I'm stumped.

Sincere thanks,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17106, 14 replies
Thread Started 5/15/2018 9:05:28 AM
View Counter=113
Location=-- -- 
Joined=7 years ago   MB Posts=58  
Moderator
Steven.G
Myrtle Beach, SC USA
Rank: Commander

x = myfieldstrinng (or whatever it's called)

if x.substr(x.size(),1) = "," then

   x = x.substr(1,x.size()-1)

endif

Steven Green
Senior Software Engineer
Paradox Support Specialist DOS/WIN

Prestwood IT Solutions
8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610
Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
 Posted 95 days ago
Comment Quote
About Steven.G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #17107 (Level 2) and Parent is 17106
Reply Posted 5/15/2018 9:15:02 AM
Location=Myrtle Beach, SC USA 
Joined=23 months ago   MB Posts=197  
Lothar.K
-- --
Rank: Cadet 4th Year
Quote:
Originally Posted by Steven.G

x = myfieldstrinng (or whatever it's called)

if x.substr(x.size(),1) = "," then

   x = x.substr(1,x.size()-1)

endif


Hi Steven, I very much appreciate the super-speedy response, but unfortunately need a bit more help to apply your suggestion.

The result of the existing code is a text file called Export.CSV.

Were the result a table, I assume that I would Scan it, and apply your code to the last field of each record in sequence.

But in my situation, would I first import the CSV, create the table, and then scan it?

Is that the general idea? 

Thanks again,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17108 (Level 1.1)  Reply to 17107 and Parent is 17106
Thread Started 5/15/2018 9:43:04 AM
Location=-- -- 
Joined=7 years ago   MB Posts=58  
Moderator
Steven.G
Myrtle Beach, SC USA
Rank: Commander

from your original description, you want to scan the table before you make the export file

Steven Green
Senior Software Engineer
Paradox Support Specialist DOS/WIN

Prestwood IT Solutions
8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610
Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
 Posted 95 days ago
Comment Quote
About Steven.G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #17109 (Level 3) and Parent is 17106
Reply Posted 5/15/2018 9:51:24 AM
Location=Myrtle Beach, SC USA 
Joined=23 months ago   MB Posts=197  
Lothar.K
-- --
Rank: Cadet 4th Year

Hi again,

Then I may have communicated poorly.

I very much appreciate your kind help, and will experiment further. 

All the best,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17110 (Level 4) and Parent is 17106
Reply Posted 5/15/2018 9:54:17 AM
Location=-- -- 
Joined=7 years ago   MB Posts=58  
rum
Frankfort, KY USA
Rank: Cadet 4th Year

var
    ts textStream
    inputLine string
    inputFlds Array[] string
    inputLineArray Array[] string
   LenLineArray LongInt
   cntLineArray LongInt
 
 
endvar

        ; Read a Line from file
        ; Save Diagnostics
        ; Close Stream

inputLineNumber = 0
; Open the file as a TextStream

; Open the Text Stream (Import File)
If ts.open("C:\\TEMP\MYFILE","r") then
  ; Read ALL from fileinto an array
  ts.readline(inputLineArray)
 
  ; Count how many lines I have in the array
  LenLineArray = inputLineArray.Size()
  cntLineArray =0

; Loop through the lines one at a time
  While cntLineArray < LenLineArray ;      Processing
           cntLineArray = cntLineArray + 1
           inputLine = inputLineArray[cntLineArray]

            ;;DO YOUR STUFF TO inputLine

   endwhile
else
    errorshow()
    msgstop("Data File Error", "Could not open data file ...")
endif

 Posted 95 days ago
Comment Quote
About rum -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread with a verified email.
Member pending approval.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17111 (Level 5) and Parent is 17106
Reply Posted 5/15/2018 9:58:31 AM
Location=Frankfort, KY USA 
Joined=14 months ago   MB Posts=60  
Lothar.K
-- --
Rank: Cadet 4th Year

Hi,

Please accept my very sincere thanks,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17112 (Level 6) and Parent is 17106
Reply Posted 5/15/2018 10:05:16 AM
Location=-- -- 
Joined=7 years ago   MB Posts=58  
Lothar.K
-- --
Rank: Cadet 4th Year

Hi again,

Putting these two ideas together, I understand that I would be applying Steven's suggestion:

x = myfieldstrinng (or whatever it's called)

if x.substr(x.size(),1) = "," then

   x = x.substr(1,x.size()-1)

to each entry in the Array suggested by Rum as InputLine, is that correct?

If I have that right, I will soon give it a try.

Many thanks, as before,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17113 (Level 7) and Parent is 17106
Reply Posted 5/15/2018 10:18:32 AM
Location=-- -- 
Joined=7 years ago   MB Posts=58  
rum
Frankfort, KY USA
Rank: Cadet 4th Year

The following is a little more complete with both ideas put together

method test()
var
   ts textStream
   outts textStream
   inputLine string
   inputLineArray Array[] string
   LenLineArray LongInt
   cntLineArray LongInt
   inputFILE STRING
   OUTPUTFILE STRING
   OUTputLine string

endvar


inputFILE = "C:\\TEMP\MYFILE.csv"
OUTPUTFILE = "C:\\TEMP\NEWFILE.csv"


inputLineNumber = 0
; Open the file as a TextStream

; Open the Text Stream (Import File)
If ts.open(inputFILE,"r") then
  ; Read ALL from fileinto an array
  ts.readline(inputLineArray)
  ts.close()


  ; Count how many lines I have in the array
  LenLineArray = inputLineArray.Size()
  If LenLineArray > 0 then
     outTS.Open(inputFILE,"nw") ; open a new file read/write  (OVERWRITES the FILE if it exists)
     cntLineArray =0

   ; Loop through the lines one at a time
     While cntLineArray < LenLineArray ;      Processing
         cntLineArray = cntLineArray + 1
         inputLine = inputLineArray[cntLineArray]


         ;;DO YOUR STUFF TO inputLine
         if inputLine.substr(inputLine.size(),1) = "," then
                  OUTPUTLINE =inputLine.substr(1,inputLine.size()-1)
         else
                  OUTPUTLINE = inputLine
         endif
         outTS.WriteLine(OUTPUTLINE)

      endwhile
      outTS.Close()
   endif
else
    errorshow()
    msgstop("Data File Error", "Could not open data file ...")
endif

endMethod

 Posted 95 days ago
Comment Quote
About rum -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread with a verified email.
Member pending approval.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17114 (Level 8) and Parent is 17106
Reply Posted 5/15/2018 10:25:47 AM
Location=Frankfort, KY USA 
Joined=14 months ago   MB Posts=60  
rum
Frankfort, KY USA
Rank: Cadet 4th Year

All that is untested embarassed

 Posted 95 days ago
Comment Quote
About rum -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread with a verified email.
Member pending approval.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17115 (Level 9) and Parent is 17106
Reply Posted 5/15/2018 10:35:44 AM
Location=Frankfort, KY USA 
Joined=14 months ago   MB Posts=60  
Moderator
Steven.G
Myrtle Beach, SC USA
Rank: Commander

what? we're supposed to test this stuff? :-)

Steven Green
Senior Software Engineer
Paradox Support Specialist DOS/WIN

Prestwood IT Solutions
8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610
Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
 Posted 95 days ago
Comment Quote
About Steven.G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #17116 (Level 10) and Parent is 17106
Reply Posted 5/15/2018 11:17:34 AM
Location=Myrtle Beach, SC USA 
Joined=23 months ago   MB Posts=197  
Lothar.K
-- --
Rank: Cadet 4th Year

Hi again,

I've not tried experimenting with this as yet, but I noticed something I need to ask about:

Rum's more detailed version has the line:

  if inputLine.substr(inputLine.size(),1) = "," then

That would appear to be testing for a comma, but it is testing the first character in the string, or the last?

Also, about the testing:

If either, or both, of you, would like to stop by my office in New Hampshire we could arrange to have... Oh, nevermind, I'll do the testing.

Very sincere thanks, as before,

Lothar

 Posted 95 days ago (Thread Starter)
Comment Quote
About Lothar.K -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17117 (Level 11) and Parent is 17106
Reply Posted 5/15/2018 11:26:24 AM
Location=-- -- 
Joined=7 years ago   MB Posts=58  
Moderator
Steven.G
Myrtle Beach, SC USA
Rank: Commander

substr parameters are "starting from what position", "how many"

(size(),1) is the last char.. (1,size()) is the whole string

Steven Green
Senior Software Engineer
Paradox Support Specialist DOS/WIN

Prestwood IT Solutions
8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610
Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
 Posted 95 days ago
Comment Quote
About Steven.G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #17118 (Level 12) and Parent is 17106
Reply Posted 5/15/2018 11:38:34 AM
Location=Myrtle Beach, SC USA 
Joined=23 months ago   MB Posts=197  
Moderator
Steven.G
Myrtle Beach, SC USA
Rank: Commander

if we arrange to have that beer in Myrtle Beach, it's much warmer.. and we have a beach :-)

Steven Green
Senior Software Engineer
Paradox Support Specialist DOS/WIN

Prestwood IT Solutions
8421 Auburn Blvd, Suite 256, Citrus Heights, CA 95610
Office: 916-726-5675 | Fax: 916-726-5676 | http://www.prestwood.com
 Posted 95 days ago
Comment Quote
About Steven.G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #17119 (Level 13) and Parent is 17106
Reply Posted 5/15/2018 11:40:51 AM
Location=Myrtle Beach, SC USA 
Joined=23 months ago   MB Posts=197  
Most Recent Post
rum
Frankfort, KY USA
Rank: Cadet 4th Year

We have another office in Mount Pleasant(sullivans Island), maybe I will visit that office again

 Posted 95 days ago
Comment Quote
About rum -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread with a verified email.
Member pending approval.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #17120 (Level 14) and Parent is 17106
Reply Posted 5/15/2018 11:53:30 AM
Location=Frankfort, KY USA 
Joined=14 months ago   MB Posts=60  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1187A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #17106 Counter
113
Since 5/15/2018
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

1,511 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2018 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech