Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

piyush12197

Programmer
Dec 14, 2017
8
IN
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.
tablepic_otb91g.png
 
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, 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.
 
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.
 
piyush12197 said:
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

 
piyush12197 said:
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.

piyush12197 said:
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

 
Hi, olaf
when i am using that same code from you. It's not executing
Screenshot_3_y8oswf.png
 
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.
 
Hi JRB-Bldr i had work too hard but unable to solve that. so why i am asking help from you.
 
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.
 
piyush12197 said:
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".

piyush12197 said:
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

piyush12197 said:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top