Normal Topic Data Type Conversion Problem (Read 660 times)
Don Newlin
Member
*
Offline


No personal text

Posts: 12
Location: Lloydminster, Ab, CA
Joined: Mar 3rd, 2003
Data Type Conversion Problem
Jan 20th, 2004 at 7:08am
Print Post Print Post  
Can anyone help spot the problem in the second piece of code?

I am trying to program a simple list of cheques for deposit to the bank at end of day

If I use the following code, the cashiers have to enter their cashier number when adding each cheque:



** PROGRAMMING SECTION: [ GLOBAL CODE ] [] **



** PROGRAMMING SECTION: [NAME] [On Form Entry] **

If @IsNew {
      CASHIER = @PopupMenu("1;2;3","Enter Cashier Number")
      CHQDATE = @DATE
      NUMBER = @NUMBER
     }



** PROGRAMMING SECTION: [CASHIER] [On Form Entry] **


I tried to change this to entering the cashier number once at the beginning of each session using the following code, but the number converts to 0, regardless of which number they choose:



** PROGRAMMING SECTION: [ GLOBAL CODE ] [] **
Var vCashier as string
vCashier = @PopupMenu("1;2;3","Enter Cashier Number")
WriteLn(vCashier)



** PROGRAMMING SECTION: [NAME] [On Form Entry] **

If @IsNew {
      CASHIER = @TONUMBER(vCashier)
      CHQDATE = @DATE
      NUMBER = @NUMBER
     }

( With only five fields, I thought this would be one of the simplest files to convert from QA5 but I guess I was wrong as usual)

Don N.


  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Data Type Conversion Problem
Reply #1 - Jan 20th, 2004 at 12:49pm
Print Post Print Post  
Quote:
  ** PROGRAMMING SECTION: [ GLOBAL CODE ] [] **
Var vCashier as string
vCashier = @PopupMenu("1;2;3","Enter Cashier Number")
WriteLn(vCashier)


You're very close. Grin

Try declaring the variable in Global Code as Static.
stat vCashier as String


Static variables hold their value. In your current code, vCashier loses the value you chose as soon as the Global Code finishes running. By declaring it as Static, vCashier will hold it's value until you close the Form.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Don Newlin
Member
*
Offline


No personal text

Posts: 12
Location: Lloydminster, Ab, CA
Joined: Mar 3rd, 2003
Re: Data Type Conversion Problem
Reply #2 - Jan 20th, 2004 at 6:17pm
Print Post Print Post  
Thanks for the help.  That worked great.  Everything is in the manual somewhere (programming  p. 52) but it sure helps having the immediate feedback when you are learning.

One application successfully converted, 999 (or so) to go.

Don N.
  
Back to top
 
IP Logged