INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Replace command not working for integer type value for storing data vfp table from vfp program pleas

Replace command not working for integer type value for storing data vfp table from vfp program pleas

Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
CLEAR
SET TALK OFF
YES="Y"
USE chair_tb
DO WHILE YES="Y"
chair_no1=SPACE(20)
chair_height1=SPACE(20)
chair_buy_date1=SPACE(20)
@7,75,38,170 box
@4,110 SAY "chair description"
@4.9,108 SAY "_____________________"
@8,95 SAY "Chair Number : " GET chair_no1
chair_no2 = INT(VAL(chair_no1))
@11,95 SAY "chair height : " GET chair_height1
chair_height2 = INT(VAL(chair_height1))
@14,120 SAY "(MM/DD/YYYY)"
@15,95 SAY "chair buy date : " GET chair_buy_date1
chair_buy_date1 = CTOD("mm/dd/yyyy")
@18,95 SAY "IF YOU WANT MORE ENTRY(Y/N)" GET YES PICT "Y"
READ
APPEND BLANK
REPLACE chair_no WITH chair_no2
REPLACE chair_height WITH chair_height2
REPLACE chair_buy_date WITH chair_buy_date1
ENDDO
CANCEL
this is my code. where date value can successfully added but integer data are not adding any number added as 0.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Yes, that's because you have to do the conversion of inputs to INT(VAL(input) after the READ. You are doing that in the middle of defininig your input sections, and at that time all the variables are still empty strings.

Instead just prepare the data types you want the user to input anyway:

CODE

CLEAR
SET TALK OFF
YES="Y"
*USE chair_tb
DO WHILE YES="Y"
chair_no1=0
chair_height1=0
chair_buy_date1=CTOD("")
@7,75,38,170 box
@4,110 SAY "chair description"
@4.9,108 SAY "_____________________"
@8,95 SAY "Chair Number : " GET chair_no1
@11,95 SAY "chair height : " GET chair_height1
@14,120 SAY "(MM/DD/YYYY)"
@15,95 SAY "chair buy date : " GET chair_buy_date1
@18,95 SAY "IF YOU WANT MORE ENTRY(Y/N)" GET YES PICT "Y"
READ
APPEND BLANK 
REPLACE chair_no WITH chair_no1 ;
   ,    chair_height WITH chair_height1 ;
   ,    chair_buy_date WITH chair_buy_date1
ENDDO
CANCEL 

Besides this is legacy screen programming. You'll want to go to forum forum182: Microsoft: FoxPro (old versions 1 to 2.6), even though you're using VFP9 to program this. Note: I could also change from APPEND+REPLACE to INSERT-SQL, which does both the append and insert data in one go, at least bundle all single field replacements into one replace, that should also be legacy compatible. If you want to learn something new, use a form, put on textbox controls and read about the controlsource property.

Bye, Olaf.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
Hi, Olaf thanks for your reply.
please help me. I am in trouble. I am not able to find correct answer or correct thread. please can u write that code for me.
please i am requesting to you.
and sorry for my english. i am not good in english.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Didn't I already do?

Bye, Olaf.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Quote (piyush12197)

but integer data are not adding any number added

You say that it is not working but you have not told us how you know that.
* Did you get an Error Message when the REPLACE line is executed?
* Did you check the new value before executing the REPLACE line?

Since your REPLACE lines follow and APPEND BLANK line, you will not be Adding any number to a previous one, but instead you are putting an input number into an empty blank record field.

We know from years of experience that replacing an Integer field value with another Integer value works. So help us better understand your problem.

What steps did you do yourself to try to examine the problem?
* Did you put a Breakpoint on the code you want to examine and then do an ACTIVATE WINDOW TRACE before running the code?
* Or did you put a SET STEP ON command in just prior to the line of code to examine?

Also your OLD, pre-VFP code format of @row,column implies that you are not using VFP code. Why not?

The more we know about your situation, the better we can advise you.

Good Luck,
JRB-Bldr

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Quote (piyush12197)

please can u write that code for me.

Perhaps you mistake the purpose of this forum.
We are not here to GIVE YOU CODE or WRITE YOUR CODE FOR YOU, but instead to ADVISE you on how to fix what you are doing or HOW TO APPROACH a problem.

Quote (piyush12197)

I am not able to find correct answer or correct thread
If you follow the advice offered here you should be able to correct the problem YOURSELF.

Good Luck,
JRB-Bldr

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
Hi, olaf
when i am using that same code from you. It's not executing

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Remove the SET STEP ON, or while you're at it, get to learn the debugger. This is what I used to inspect what's going on and what values are in your variables short before the APPEND BLANK and the REPLACEs.
I edited my code above.

Bye, Olaf.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
Hi JRB-Bldr i had work too hard but unable to solve that. so why i am asking help from you.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
thankyou olaf, thankyou very much. in short love u.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

You're welcome, just watch out phrasing a bit. Indeed all you wanted to know is what's wrong and why you get 0 in the table records. A totally valid question. That was simply a data binding error. You only have the values in the variables you use in the @SAY inputs after the READ. So either you would have need to put the INT(VAL()) later or - as I did - simply initialize the variables used like you did with the YES variable, before binding them to the @SAY and then use them and not secondary variables. Why use two sets of variables?

Last not least, You may check whether your dates really are as you want them, SET DATE TO DMY sets the wanted order of day first, then month and not as Americans do. You get the same effect with SET DATE BRITISH.

Bye, Olaf.

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

(OP)
Thanks Again

RE: Replace command not working for integer type value for storing data vfp table from vfp program pleas

Quote (piyush12197)

i had work too hard but unable to solve that

We have all had to work "Too Hard" from time to time. That is nothing unusual.
To get the code working sometimes it just requires us to have to work a little more "Too Hard".

Quote (piyush12197)

why i am asking help from you

Asking for Help is one thing.
We are here to Assist/Advise anyone who asks with Specific and Detailed Questions as long as they are not: Promoting, selling, recruiting, coursework (that is classwork) and thesis posting

Quote (piyush12197)

please can u write that code for me.

But asking for SOMEONE TO WRITE YOUR CODE or SOMEONE TO GIVE YOU THE CODE is a totally different thing.

Good Luck
JRB-Bldr

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close