![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I think you'll have to call a subroutine. Put a "CALL MYSUB" in line 8 and write, compile and catalog MYSUB subroutine. It will have a single argument, in which you pass back the data to be used in the "synonym". Look in the ref man for ACCESS. You can access each item by using ACCESS(3) - as in ACCESS(3)<9> or ACCESS(3)<2,5> etc. The are many examples in here - just google cdp. You can do anything you want with a CALL from a dictionary. I'm fairly sure that, once you have mastered this, we'll see fewer requests like this. Let's know how you get on. Do you need help with the PickBasic code to extract the leading alpha chars? |
#2
| |||
| |||
|
|
Folks my posting a few weeks back revolved around getting the front numeric characters of a stream of record IDs like the following: R123 R12345 RC12 RC123 RC12345 S12 SV123456 SVX679101 SVX123 and the solution kindly proposed by a helpful poster was a synonym like the one below called TYPE 001 S 002 0 003 TYPE 004 005 006 007 008 MCA 009 L 010 6 This synonym gave me all the alphas in the record ID so for the above data I got 1 to 3 alpha characters, which was great as it allowed me to seperate the data for reporting purposes, as the leading alphas indicated the type of job (Production, repair, R&D, marketing etc etc) All was going well until today, when horrors, I noticed that some users had also been raising job numbers in the form R123A RC1234C SZY45T etc, so that my TYPE synonym stopped working the way I wanted as it now returned results like RA, RCC, SZYT for the data whereas I just wanted just the first alpha part before the numeric, ie R, RC, SZY. Is their any simple tweak that I can do to my synonym to get just those pesky leading alpha characters? Note that the number of leading alphas and the following numerics can vary, but the end alpha (after the numeric) if present at all, is only ever 1 character. |
#3
| |||
| |||
|
|
Mike thanks for the feedback - I thought it might come down to this as I suspected that what I was wanting was a bit too arcane for a "standard" synonym. Most of the synonyms I have which call up subroutines have been to do relatively mundane things like sum up multivalues in another file. I've had a few written for me many years back and cloned the rest, but I'm certainly no dab hand at manipulating strings, so any code snippets appreciated. |
#4
| |||
| |||
|
|
1. Update data entry programs to prohibit this type of job number! 2. Educate users so that they don't use this sort of job number! 3. The practical way seeing these items already exist - write a basic subroutine to parse the ID and return only the leading alpha characters. You will be able to call the subroutine from a dictionary item (sorry - I don't know the format for D3 - possibly a CALLX - someone else will help you there). But seriously - you should be investigating point 1 above so that ID's have a standard format. |
#5
| |||
| |||
|
|
Is their any simple tweak that I can do to my synonym to get just those pesky leading alpha characters? Note that the number of leading alphas and the following numerics can vary, but the end alpha (after the numeric) if present at all, is only ever 1 character. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
actually... i could have eliminated a step... try: f1;(mca);p;p;(L0);1;_;c1;_;[];=;JT end;p;(L0);c1;_;c1;-;[];(mca);~end |
#8
| |||
| |||
|
|
actually... i could have eliminated a step... try: f1;(mca);p;p;(L0);1;_;c1;_;[];=;JT end;p;(L0);c1;_;c1;-;[];(mca);~end |
#9
| |||
| |||
|
|
It is SO easy to make a mistake - as Dave has done. No mistake! <wink |
#10
| |||
| |||
|
|
subroutine extract.alpha(fld) fx = '' for i = 1 to len(fld) if alpha(fld[i,1]) then fx := fld[i,1] else exit next i fld = fx return |
![]() |
| Thread Tools | |
| Display Modes | |
| |