Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find getl problems
#1
I am trying to create a macros to extract phone numbers from a text field, but my problem is the text field was poorely created and is in no order at all. So i was thinking if theres a way to do all this it would save me reorganising the whole file.
1.store whole text to a string
2.find the name of the customer
3.extract the number from this line
4.store in a variable
5.output to qm
would this be posible? or is there any examples of how to do parts 2 and 3 of my problem.
Thanks for any help or answers.
#2
you don't show how the text looks
#3
Gintaras Wrote:you don't show how the text looks
its like

Cutsomername address ( phone number )
john doe: 1 park lane timbucktoo, Austria ( 0800 0000000 )
Chris Crinkle: 7 Silk Road North Pole ( +044 444 4444444 )

Its mainly all like the above, but the odd times the address and phone number are back to front eg:

Cutsomername ( phone number ) address
john doe ( 0800 0000000 ) 1 park lane timbucktoo, Austria
Chris Crinkle ( +044 444 4444444 ) 7 Silk Road North Pole

Or even

( 0800 0000000 ) john doe 1 park lane timbucktoo, Austria
7 Silk Road North Pole Chris Crinkle ( +044 444 4444444 )

This is why im need a macro to find the numbers only. The numbers are always in brackets if that helps.
#4
Having the numbers in the brackets really helps!!

Search for "tok" in the help file.
This is how you tokenize (split) a string.

You'll want to play around with using " ( " and " ) " as delimiters.

Then out on a for statement.

Just check the help file, it'll be fun to figure out...and totally useful in your programming.

Jimmy Vig
#5
Code:
Copy      Help
str s = "one, (two + three) four five"
ARRAY(str) arr arr2
int i nt
nt = tok(s arr 3 ", ()" 8 arr2)
for(i 0 nt) out "'%s' '%s'" arr[i] arr2[i]
Output:
'one' ', ('
'two + three' ') '
'four' ' '

Here is the example in the help file you'll want to model your code off of.
#6
TheVig Wrote:
Code:
Copy      Help
str s = "one, (two + three) four five"
ARRAY(str) arr arr2
int i nt
nt = tok(s arr 3 ", ()" 8 arr2)
for(i 0 nt) out "'%s' '%s'" arr[i] arr2[i]
Output:
'one' ', ('
'two + three' ') '
'four' ' '

Here is the example in the help file you'll want to model your code off of.
Thanks that great and solves how to get the number from the line, any ideas on how i would i get the line from the string only knowing the customer name.
#7
ok i got this is what i got from what you told me, but still dont know how to get the whole line a word is on. I believe what i have wont work if the number is first in the line either. Not too worried as it seems only 1 or 2 are in that order from a quick scroll through.
Im not 100% sure how i come up with this code because i do not understand how these delimeters work full yet all i know is it passed the test.
Function Function3
Code:
Copy      Help
str d.all(256 0 0)
d.set(1 0 33); d[160]=1
d[34]=1; d['<']=1; d['>']=1
str s = "john doe 1 park lane timbucktoo, Austria ( 0800 0000000 ) "
lpstr s1 s2 s3
int i
int nt = tok(s s1 4 "()" 8 s3)
for(i 1 nt 0)
,str s5=s2
,s5.findreplace(")" "" 2 " .")
,s5.findreplace("(" "" 2 " .")
,s5.trim
,out s5
,end
#8
i am still struggling with getting the whole line a word is on. Is there a way of numbering all the lines and then when i search for a name it stores the line number into a variable. this would help me alot thx!
#9
use array

str s="multiline text"
ARRAY(str) a=s
int i
for i 0 a.len
,out a[i]
#10
thats so simple and efective idk why i couldnt figure it out like that last time i tried. anyways im finished thx vig and gint!
Function Function5
Code:
Copy      Help
str s.getwintext(id(12 win("Customer Controlls" "#32770")))
str s6="john doe"
str s7="*"
s6+s7
s6-s7
ARRAY(str) a=s
int i
for i 0 a.len
,if matchw(a[i]  s6)
,,out a[i]
,,goto next
;next
str d.all(256 0 0)
d.set(1 0 33); d[160]=1
d[34]=1; d['<']=1; d['>']=1
lpstr s1 s2 s3
int i1
int nt = tok(a[i] s1 4 "()" 8 s3)
for(i1 1 nt 0)
,str s5=s2
,s5.findreplace(")" "" 2 " .")
,s5.findreplace("(" "" 2 " .")
,s5.findreplace("," "" 4 " .")
,s5.trim
,out s5
,end


Forum Jump:


Users browsing this thread: 2 Guest(s)