I am having trouble using the AT function. Please see the attached piece of code. The AT function consistently returns Zero.
I would deeply appreciate any help
Thanks in advance
Peter
#include <hmg.ch>
Private S11:= "", S12:= "", S21:= "", S22:= "", S31:="", S32:= ""
Private Location := "", SalaBrak := "", Nationality := "", CurEmployer := ""
Private V_Location := "", V_SalaBrak := "", V_Nationality := "", V_CurEmployer := ""
Location = "Location"
SalaBrak = "Salary Bracket"
Nationlity = "Nationality"
CurEmployer = "Current Employer"
S11 = "Location: Dubai- United Arab Emirates Salary Bracket: $2001 - $3000"
S12 = "Nationality: Romanian Current Employer: Government"
S21 = "Location: Dubai- United Arab Emirates Salary Bracket: $4001 - $5000"
S22 = "Nationality: Irish Current Employer: Seeking work in Dubai"
S31 = "Location: Dubai- United Arab Emirates Salary Bracket: $4001 - $5000"
S32 = "Nationality: British (UK) Current Employer: Not Mentioned"
Proclocationline(S11)
ProcNationalityLine(S12)
Proclocationline(S21)
ProcNationalityLine(S22)
Proclocationline(S31)
ProcNationalityLine(S32)
RETURN
Static Procedure ProcLocationLine(LineInput)
Local LocPtr := 0, LocLen := 0, SalPtr := 0, SalLen := 0
LocLen = 10
SalLen = 16
LocPtr = AT(LineInput, Location)
SalPtr = AT(LineInput, SalaBrak)
V_Location = SUBSTR(LineInput, (LocPtr + LocLen), (SalPtr - LocLen - 1))
V_SalaBrak = SUBSTR(LineInput, (SalPtr + SalLen))
RETURN
*
*
*
Static Procedure ProcNationalityLine(LineInput)
Local NatPtr := 0, NatLen:= 0, EmpPtr := 0, EmpLen := 0
NatLen = 13
EmpLen = 18
NatPtr = AT(LineInput, Nationality)
EmpPtr = AT(LineInput, CurEmployer)
V_Nationality = SUBSTR(LineInput, NatLen, (EmpPtr - NatLen))
V_CurEmployer = SUBSTR(LineInput, (EmpPtr + EmpLen))
RETURN
*
Having trouble with AT Function Behaviour
Moderator: Rathinagiri
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Having trouble with AT Function Behaviour
Hi Peter
Standard format of AT() function :
Code: Select all
AT( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
Code: Select all
LocPtr = AT(LineInput, Location )
Code: Select all
LocPtr = AT(Location, LineInput)
PS: You can find more info at here.
Viva INTERNATIONAL HMG
Re: Having trouble with AT Function Behaviour
Peter here is a quick example;
a = 'Hello Location: Mexico and more'
b = at('Location:', a)
c = substr(a,b+10,1000) // use 1000 not knowing length of variable
d = substr(c,1,at(' ',c))
msgbox(d) //will return Mexico
It may be easier to create a table with fields for information. Then it will be easier to find different values.
Franco:
a = 'Hello Location: Mexico and more'
b = at('Location:', a)
c = substr(a,b+10,1000) // use 1000 not knowing length of variable
d = substr(c,1,at(' ',c))
msgbox(d) //will return Mexico
It may be easier to create a table with fields for information. Then it will be easier to find different values.
Franco:
All The Best,
Franco
Canada
Franco
Canada
Re: Having trouble with AT Function Behaviour
Thank`s Edward I did not know this.
All The Best,
Franco
Canada
Franco
Canada