View previous topic :: View next topic
|
Author |
Message |
sumanthmain
New User
Joined: 22 Aug 2005 Posts: 14
|
|
|
|
HI
Dear fourm mates
I Have a dought about pseudo varibles in p/1. could u plz give me brief explanation about that.
means
1) what is pseudo varibles ?
2)In which scenario we can use pseudo varibles ?
3) Give me one real time example?
Advance thanks
sumanth |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi Sumanth,
Hope this helps...
(1) Pseudovariable:- A builtin function that can be used in the left hand side of an assignment statement as if it was a variable is called a pseudovariable.
(2)It's used when you need to assign value to the location which is accessed by the builtin function.Ex:-ONCHAR,ONSOURCE,SUBSTR
(3)Real time example:-
SUBSTR is a builtin function.It can be used as a pseudovariable.
Say,DATE1 is declared as CHAR(6) and it's in YYMMDD form.Now what ever may be the month,you need to force the month to December.This can be done as below.
SUBSTR(DATE1,3,2) = '12';
Do correct me for any mistake(s).
Thanks!
Sridevi. |
|
Back to top |
|
|
sumanthmain
New User
Joined: 22 Aug 2005 Posts: 14
|
|
|
|
Thanks sridevi for ur prompt reply.
Could u plz explain how we can use pseduo varibles in ONCHAR And ONSOURE AND IMG Funtion.
Advance thanks
regards
sumanth |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi Sumanth,
ONCHAR and ONSOURCE buitin functions can be used only in ON units. These are useful for debugging,because it gives info on how particular condition has been raised. ONCHAR returns the character that raised the CONVERSION or the ERROR condition.ONSOURCE returns the content of the field that raised the CONVERSION or the ERROR condition.Both, can be used as pseudovariable as below.
Example: ONCHAR = '0';
ONSOURCE = '0';
This means you have reset both the character and the field that raised the condition to zero.
I guess,IMAG is the builtin function/pseudovariable you meant and misspelt it as IMG.
Say,A is a complex number of the form(X+iY) where X is real part and Y is imaginary part.To assign value to Y,IMAG pseudovariable can be used as below.
DCL A FLOAT DECIMAL(15) COMPLEX;
IMAG(A) = 1.414;
Thanks!
Sridevi. |
|
Back to top |
|
|
|