Home > database >  Refer new PB code
Refer new PB code

Time:09-15

Standardization of PB code below, add enough comments

GetExpVal. SRF
//get in line with the expression string values, each words separated by Spaces,
//and be a correct expression, revoke the error checking code
//parameters description:
//ai_how_getvar=0 from the FYVAL GCFYB
//ai_how_getvar=1 in the GCFYB tempVAL
//ai_how_getvar=2 in the gds_number_varb FYVAL
//return null said error

Ls_sharestack string ls_wordarr [], []
String ls_wordtype ls_wordstr, ls_temp, ls_wordfxmes
The integer li_wordnum opndtop, optrtop li_wordcount, li_pos
Dec {6} ld_cval

IF isNull (as_expstr) OR trim (as_expstr)='THEN
RETURN 0
END the IF

IF right (as_expstr, 1) & lt;> "' THEN as_expstr +='

Li_wordnum=0
Li_pos=pos (as_expstr, ' ')
The DO WHILE li_pos & gt; 1
Ls_wordstr=left (as_expstr li_pos - 1)
CHOOSE a CASE ls_wordstr
CASE '+', '-' and '*', '/', '! ', '(',') 'and'=', '& gt; ', '& lt; ', '& gt;=', '& lt;=', '& lt;> ', 'NOT' AND 'AND', 'OR'
Ls_wordtype='symbols'
In CASE the ELSE
IF IsNumber (ls_wordstr) THEN
Ls_wordtype='digital'
The ELSE
IF right (ls_wordstr, 1)=') THEN
Ls_wordtype='function'
The ELSE
Ls_wordtype='variables'
END the IF
END the IF
The END CHOOSE
Li_wordnum + +
Ls_wordarr [li_wordnum * 2]=ls_wordstr
Ls_wordarr] [li_wordnum * 2-1=ls_wordtype
As_expstr=replace (li_pos as_expstr, 1, ' ')
Li_pos=pos (as_expstr, ' ')
LOOP

Ls_sharestack [li_wordnum + 2]='#'//to the left as symbolic stack, stack bottom bracket for sentence #, the right for computation stack

Opndtop=0
Optrtop=li_wordnum + 2

FOR TO li_wordnum li_wordcount=1 + 1
IF li_wordcount=li_wordnum + 1 THEN
Ls_wordtype='symbols'
Ls_wordstr='#'
The ELSE
Ls_wordtype=ls_wordarr] [li_wordcount * 2-1
Ls_wordstr=ls_wordarr [li_wordcount * 2]
END the IF

CHOOSE a CASE ls_wordtype
CASE 'variables'
//to find the value of the variable
IF ai_how_getvar=0 THEN
Ls_wordstr=gwf_getvar_from_dw_gcfy (ls_wordstr, 0)
ELSEIF ai_how_getvar=1 THEN
Ls_wordstr=gwf_getvar_from_dw_gcfy (ls_wordstr, 1)
The ELSE
Ls_wordstr=string (uf_getvarval_from_gds (ls_wordstr))
END the IF
IF isNull (ls_wordstr) THEN
SetNull (ld_cval)
RETURN ld_cvalEND IF
Opndtop++
Ls_sharestack [opndtop]=ls_wordstr
CASE 'digital'
Opndtop++
IF right (ls_wordstr, 1)='%' THEN
Ls_wordstr=string (dec (left (ls_wordstr, len (ls_wordstr) - 1))/100)
ELSEIF right (trim (ls_wordstr), 2)='%' THEN
Ls_wordstr=string (dec (left (ls_wordstr, len (ls_wordstr) - 2))/100)
END the IF
Ls_sharestack [opndtop]=ls_wordstr
CASE 'symbols'
IF ls_wordstr='-' THEN
IF li_wordcount=1 THEN ls_wordstr='! '
IF li_wordcount & gt; 1 THEN
IF ls_wordarr [li_wordcount * 2-2]='(' THEN ls_wordstr='! '
END the IF
END the IF

CHOOSE_ENTRY:
Ls_wordfxmes=precede (ls_sharestack [optrtop], ls_wordstr)
CHOOSE a CASE ls_wordfxmes
CASE '& gt; '
CHOOSE a CASE ls_sharestack [optrtop]
CASE '! '
Ls_sharestack [opndtop]=string (- dec (ls_sharestack [opndtop]))
In CASE the '+'
Opndtop -
Ls_sharestack [opndtop]=string (dec (ls_sharestack [opndtop]) + & amp;
Dec (ls_sharestack [opndtop + 1]))
In CASE the '-'
Opndtop -
Ls_sharestack [opndtop]=string (dec (ls_sharestack [opndtop]) - & amp;
Dec (ls_sharestack [opndtop + 1]))
CASE '*'
Opndtop -
Ls_sharestack [opndtop]=string (dec (ls_sharestack [opndtop]) * & amp;
Dec (ls_sharestack [opndtop + 1]))
CASE '/'
IF dec (ls_sharestack [opndtop])=0 THEN
MessageBox (' mistakes', 'in addition to the zero error! ')
SetNull (ld_cval)
RETURN ld_cval
END the IF
Opndtop -
Ls_sharestack [opndtop]=string (dec (ls_sharestack [opndtop])/& amp;
Dec (ls_sharestack [opndtop + 1]))

CASE '='
Opndtop -
IF dec (ls_sharestack [opndtop])=dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE '& gt; '
Opndtop -
IF dec (ls_sharestack [opndtop]) & gt; Dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE '& lt; '
Opndtop -
IF dec (ls_sharestack [opndtop]) & lt; Dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE '& gt;='
Opndtop -
IF dec (ls_sharestack [opndtop]) & gt;=dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE '& lt;='
Opndtop -
IF dec (ls_sharestack [opndtop]) & lt;=dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE '& lt;> '
Opndtop -
IF dec (ls_sharestack [opndtop]) & lt;> Dec (ls_sharestack [opndtop + 1]), THEN the
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE 'NOT'
IF dec (ls_sharestack [opndtop])=0 THEN
Ls_sharestack [opndtop]='1'
The ELSE
Ls_sharestack [opndtop]='0'
END the IF
CASE 'AND'
IF dec (ls_sharestack [opndtop]) * dec (ls_sharestack [opndtop + 1])=0 THEN
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related