dbTalk Databases Forums  

Query to find just alpha chars?

comp.databases.paradox comp.databases.paradox


Discuss Query to find just alpha chars? in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Rodney Wise
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 11:02 AM






Joe,

Using the Delete Query (as Steve has told you) is the best way to go.

However... be very careful... These items (with the Alpha characters) may
be linked to items in other tables. Once you delete them, the link is
broken and their children will be lost. (still exist, but not linked to
their parent item).

Unless you are absolutely "sure" that these items are NOT linked to other
items in other tables... I wouldn't simply delete them...

But if you do, I would recommend that you immediately rename the "Answer.db"
table which will be located in your Private directory to some other name...
such as "save.db" or something.... You may discover that you'll need to
add them back to their original table.



--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney



Reply With Quote
  #12  
Old   
Rodney Wise
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 11:09 AM






Joe,

Also note... if a transaction history has been established for one of these
items... such as "16L0A1061A"... then your historical reporting will be all
wrong.. because the sales data was based on that item number. Your
inventory values and totals will be all wrong too.

Typically, it should be impossible to delete an inventory item once a
transaction on it has occurred... such as purchase or sale. Doing so will
effect the entire system.

If you change the item number, it will also have to be changed on every
invoice, sales reciept, historical report, etc., etc., etc... That is whay
it is illadvised. If a customer would bring one of these items back for a
refund, their reciept will no longer have a valid item listed on it.


--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney



Reply With Quote
  #13  
Old   
JoeSpareBedroom
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 11:39 AM



"Rodney Wise" <NSpamPlease_rodney1 (AT) bellsouth (DOT) net> wrote

Quote:
Joe,

Also note... if a transaction history has been established for one of
these items... such as "16L0A1061A"... then your historical reporting will
be all wrong.. because the sales data was based on that item number.
Your inventory values and totals will be all wrong too.

Typically, it should be impossible to delete an inventory item once a
transaction on it has occurred... such as purchase or sale. Doing so will
effect the entire system.

If you change the item number, it will also have to be changed on every
invoice, sales reciept, historical report, etc., etc., etc... That is
whay it is illadvised. If a customer would bring one of these items back
for a refund, their reciept will no longer have a valid item listed on it.

Fortunately, Rodney, this is a much simpler situation. These are
freestanding tables containing data (sometimes nice data, sometimes ugly)
sent to us from companies we buy from or sell to. Sole purpose, as stated by
our contacts: "Don't call me unless you know we carry the item. I'll send
you the data so you can check first".




Reply With Quote
  #14  
Old   
Rodney Wise
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 01:10 PM



Joe,

When you said , "Strawberry pop tarts"... is presumed the data was coming
from a retail inventory and therefore concluded with my other assumptions
that it might be connected to other transaction type data.

The task of parsing data or cleaning up data can originate from many
different requirements. You obviously know your needs better then anyone
here... sorry for being so presumptuous.


--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney



Reply With Quote
  #15  
Old   
Randy
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 06:10 PM



You can use a scan and chr() to determine whether a character is to be
removed. The following script, where "thestr" is the sample value,
will remove all non numerical characters regardless of where they are
located in the string. Also removed are symbol characters. It involves
a pair of FOR loops. One to remove the Low and one to remove High
ascii characters. It is written in pdox for windows, perhaps you can
translate into Pdox 4 -- or maybe someone else can.

method run(var eventInfo Event)
var
sval,cv smallint
i longint
thestr string
endvar

thestr = "!!FRHabd1155mLOz99ssZXS~"

ignoreCaseInStringCompares (No)
cv=58

;REMOVE HIGH CHARS

for i from 1 to 69
while(true)
sval=thestr.search(chr(cv))
if sval=0 then quitloop endif
if sval<thestr.size() then
thestr=thestr.substr(1,sval-1)+""+thestr.substr(sval+1,255)
else
thestr=thestr.substr(1,sval-1)
endif
endwhile
cv=cv+1
endfor

thestr.view("High chars eliminated")


;REMOVE LOW CHARS

cv=33
for i from 1 to 15
while(true)
sval=thestr.search(chr(cv))
if sval=0 then quitloop endif
if sval<thestr.size() then
thestr=thestr.substr(1,sval-1)+""+thestr.substr(sval+1,255)
else
thestr=thestr.substr(1,sval-1)
endif
endwhile
cv=cv+1
endfor

thestr.view("Low chars eliminated")

ignoreCaseInStringCompares (No)

endMethod


Good luck with this.

Randy



On Mar 30, 7:26?am, "JoeSpareBedroom" <dishborea... (AT) yahoo (DOT) com> wrote:
Quote:
I suspect this can't be done, but who knows? I've got a field that should
contain only UPC numbers, but the raw data file often contains quite a few
erroneous alpha chars. They're just a visual annoyance for the viewer, but
it would be nice to get rid of them. Is there a way to do this with a query,
or would I need to scan the table with a script that hunts for ascii values
within a certain range? I'm using PdoxDOS 4.x.



Reply With Quote
  #16  
Old   
Steven Green
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-30-2007 , 07:53 PM



Quote:
perhaps you can translate into Pdox 4
once again, the simple elegance of PdoxDOS.. I already posted that code..
three lines, not half a page (g)

--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales

Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Sports Memorabilia and Trading Cards
"Randy" <rprenphoto (AT) aol (DOT) com> wrote

Quote:
You can use a scan and chr() to determine whether a character is to be
removed. The following script, where "thestr" is the sample value,
will remove all non numerical characters regardless of where they are
located in the string. Also removed are symbol characters. It involves
a pair of FOR loops. One to remove the Low and one to remove High
ascii characters. It is written in pdox for windows, perhaps you can
translate into Pdox 4 -- or maybe someone else can.

method run(var eventInfo Event)
var
sval,cv smallint
i longint
thestr string
endvar

thestr = "!!FRHabd1155mLOz99ssZXS~"

ignoreCaseInStringCompares (No)
cv=58

;REMOVE HIGH CHARS

for i from 1 to 69
while(true)
sval=thestr.search(chr(cv))
if sval=0 then quitloop endif
if sval<thestr.size() then
thestr=thestr.substr(1,sval-1)+""+thestr.substr(sval+1,255)
else
thestr=thestr.substr(1,sval-1)
endif
endwhile
cv=cv+1
endfor

thestr.view("High chars eliminated")


;REMOVE LOW CHARS

cv=33
for i from 1 to 15
while(true)
sval=thestr.search(chr(cv))
if sval=0 then quitloop endif
if sval<thestr.size() then
thestr=thestr.substr(1,sval-1)+""+thestr.substr(sval+1,255)
else
thestr=thestr.substr(1,sval-1)
endif
endwhile
cv=cv+1
endfor

thestr.view("Low chars eliminated")

ignoreCaseInStringCompares (No)

endMethod


Good luck with this.

Randy



On Mar 30, 7:26?am, "JoeSpareBedroom" <dishborea... (AT) yahoo (DOT) com> wrote:
I suspect this can't be done, but who knows? I've got a field that should
contain only UPC numbers, but the raw data file often contains quite a
few
erroneous alpha chars. They're just a visual annoyance for the viewer,
but
it would be nice to get rid of them. Is there a way to do this with a
query,
or would I need to scan the table with a script that hunts for ascii
values
within a certain range? I'm using PdoxDOS 4.x.





Reply With Quote
  #17  
Old   
Michael Kennedy
 
Posts: n/a

Default Re: Query to find just alpha chars? - 03-31-2007 , 07:07 AM



Joe,

To remove just the ALPHA stuff, you could use an approach like Steve's.

If there's other cr*p in here, you might need some code like Randy's, and,
for PDoxDOS, it might be something like the following - if you're deleting
some records WITHIN the SCAN loop, then the code needs to be re-structured
slightly, so that records just after the deleted ones are not skipped within
the SCAN...

- Mike

; Remove all non-numeric chars

CoEdit "Table..."
Scan
[Field1] = Nums_Only([Field1])
[Field2] = Nums_Only([Field2])
...
If Len([Field1]) <> 10 Then
; Delete that record ???, and WATCH/Adjust the SCAN pointer!!...
Else
; Retain that record ???
PostRecord
EndIf
EndScan
....
Proc Nums_Only(x1)
Private x2,x3
For x2 from 1 to Len(x1)
x3 = SubStr(x1,x2,1)
If x3 < "0" or x3 > "9" Then
x1 = SubStr(x1,1,x2-1) + SubStr(x1,x2+1,255)
x2 = x2 - 1
EndIf
EndFor
Return x1
EndProc



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.