Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Puzzle: Every trick creates a booby-trap
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Puzzle: Every trick creates a booby-trap
Environment versions
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01042614
Message ID:
01042614
Views:
44
This is not a bug,
but only a consequence
of the fact that VFP doesn't have indexes with variable-length key,
and therefore the team is invented an workaround:
CLEAR
ON ERROR ? MESSAGE()

? "1 CHARACTER VARCHAR(10)"

? "RTRIM NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on Test(RTRIM(A)) TAG t1
INSERT INTO testindex VALUES ('1')

? "LTRIM NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on Test(LTRIM(A)) TAG t2
INSERT INTO testindex VALUES ('1')

? "RTRIM INDIRECT NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on TESTR(A) TAG t3
INSERT INTO testindex VALUES ('1')

? "LTRIM INDIRECT NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on TESTL(A) TAG t4
INSERT INTO testindex VALUES ('1')

?
? "2 CHARACTERS VARCHAR(10)"

? "RTRIM NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on Test(RTRIM(A)) TAG t1
INSERT INTO testindex VALUES ('12')

? "LTRIM NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on Test(LTRIM(A)) TAG t2
INSERT INTO testindex VALUES ('12')

? "RTRIM INDIRECT NOT FAIL"
CREATE CURSOR testindex (a V(10))
INDEX on TESTR(A) TAG t3
INSERT INTO testindex VALUES ('12')

? "LTRIM INDIRECT FAIL !!!!!"
CREATE CURSOR testindex (a V(10))
INDEX on TESTL(A) TAG t4
INSERT INTO testindex VALUES ('12')

PROCEDURE test(x)
	RETURN x
	
PROCEDURE TESTL(X)
	RETURN LTRIM(X)
	
PROCEDURE TESTR(X)
	RETURN RTRIM(X)
Very better if they added a clause to INDEX ON that declared the type of key,
and in this case they skipped the phase of analysis:
INDEX ON ..... TYPE V(10)
Fabio
Reply
Map
View

Click here to load this message in the networking platform