Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error with UDF within BROWSE FIELDS
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00196393
Message ID:
00196427
Views:
27
The error seems to occur when the fmttime function tries to insert the ":" into the numeric field. I changed your calltime field value to character and then changed the fmttime function to convert it to a numeric. Try running the following code:

CREATE CURSOR tmpData ;
(compid C(14), ;
phonenum C(14), ;
calltime c(4))

SELECT tmpData
INSERT INTO tmpData ;
(compid, ;
phonenum, ;
calltime) ;
VALUES ;
("100-000-000", ;
"407-313-9900", ;
"1430")

BROWSE FIELDS compid, phonenum, y=FmtTime(calltime) NOEDIT


******************************************************************
FUNCTION fmttime(lnTimeValue)
PRIVATE timestrg
IF val(lnTimeValue) < 10
timestrg = SPACE(2)+PADL(STR(val(lnTimeValue),1),2,"0")
ELSE
timestrg = STR(val(lnTimeValue),4)
ENDIF
RETURN LEFT(timestrg,2)+":"+RIGHT(timestrg,2)



>I'm getting an error in VFP that I cannot replicate in a 2.6 app. Wondering if anyone has run into this?
>
>A numeric field (representing time of day in 24hour format) is being transformed to a character field showing AM/PM. When user mouses into the field, VFP error fires (variable is not found).
>
>Code below will duplicate error:
>
>CREATE CURSOR tmpData ;
> (compid C(14), ;
> phonenum C(14), ;
> calltime N(4))
>
>SELECT tmpData
>INSERT INTO tmpData ;
> (compid, ;
> phonenum, ;
> calltime) ;
> VALUES ;
> ("100-000-000", ;
> "407-313-9900", ;
> 1430)
>
>BROWSE FIELDS compid, phonenum, y=FmtTime(calltime) NOEDIT
>
>******************************************************************
>FUNCTION fmttime(lnTimeValue)
> PRIVATE timestrg
> IF lnTimeValue < 10
> timestrg = SPACE(2)+PADL(STR(lnTimeValue,1),2,"0")
> ELSE
> timestrg = STR(lnTimeValue,4)
> ENDIF
> RETURN LEFT(timestrg,2)+":"+RIGHT(timestrg,2)
Henry Petry
AeroHunter.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform