Cannot display information.

H

Hon Seng Phuah

Guest
Hi all,

I do not understand why these code cannot work:

procedure( trSelectedResult(mainForm)
let( (selectedValue filePath revNo)
selectedValue = car(mainForm->trSearchResult->value)
if( selectedValue != nil
selectedValue = parseString(selectedValue " ")
if( eq("Email:" nthelem(1 selectedValue))
filePath = nthelem(2 selectedValue)
mainForm->trViewButton->enabled = t
printf("%s" filePath)
)
)
)
)

if I remove the printf statement, it works. Anyone has any idea what my problem is?

Thanks.
-HS Phuah
 
i think it's because then and else are missing in the
if statement.

there are two possible syntax, one with then-else and one without.

from the SKILL reference :

if(
g_condition
g_thenExpression
[ g_elseExpression ]
)
=> g_result

if(
g_condition
then g_thenExpr1 ...
[ else g_elseExpr1 ... ]
)
=> g_result

notice there are no ellipsis (...) in the first syntax, this means
only one statement is allowed. In other words, you can use
it as a shorthand for a simple if statement.

this said, i think that your code didn't work either without the
printf statement, because the second statement
(mainForm->trViewButton->enabled = t)
was actually in the else-clause which doesn't look like what
you intented. When there's no else clause you can use the
when statement when( condition expr ... ) it's easier.

hope this helps,

stéphane

ps:
also, next time you post such a question you should tell
WHAT doesn't work, not just 'it doesn't work', you'll have
better chances to get an answer.





"Hon Seng Phuah" <hsphuah@usa.com> wrote in message
news:3898598f.0404280016.635f4b2f@posting.google.com...
Hi all,

I do not understand why these code cannot work:

procedure( trSelectedResult(mainForm)
let( (selectedValue filePath revNo)
selectedValue = car(mainForm->trSearchResult->value)
if( selectedValue != nil
selectedValue = parseString(selectedValue " ")
if( eq("Email:" nthelem(1 selectedValue))
filePath = nthelem(2 selectedValue)
mainForm->trViewButton->enabled = t
printf("%s" filePath)
)
)
)
)

if I remove the printf statement, it works. Anyone has any idea what my
problem is?

Thanks.
-HS Phuah
 
You need a then in your if. Without it, you can only have two
statements, a then clause and an else clause. From what you have
written, you need the then even without the printf to have the behavior
you appear to want.

if( eq("Email:" nthelem(1 selectedValue))
then
filePath = nthelem(2 selectedValue)
mainForm->trViewButton->enabled = t
printf("%s" filePath)
)

On 28 Apr 2004 01:16:28 -0700, hsphuah@usa.com (Hon Seng Phuah) wrote:

Hi all,

I do not understand why these code cannot work:

procedure( trSelectedResult(mainForm)
let( (selectedValue filePath revNo)
selectedValue = car(mainForm->trSearchResult->value)
if( selectedValue != nil
selectedValue = parseString(selectedValue " ")
if( eq("Email:" nthelem(1 selectedValue))
filePath = nthelem(2 selectedValue)
mainForm->trViewButton->enabled = t
printf("%s" filePath)
)
)
)
)

if I remove the printf statement, it works. Anyone has any idea what my problem is?

Thanks.
-HS Phuah
 

Welcome to EDABoard.com

Sponsor

Back
Top