Page 1 of 1

Trap error with Begin Sequence

Posted: Fri May 04, 2018 9:38 pm
by hmgchang
Dear Friends,

I need help on the error trapping,
error1.JPG
This works with no errors
error1.JPG (64.23 KiB) Viewed 422 times
error2.JPG
error is not trapped
error2.JPG (79.67 KiB) Viewed 422 times
the code,
20180504_hmbk2find.zip
(7.79 KiB) Downloaded 24 times
TIA

best rgds,
Chang

Re: Trap error with Begin Sequence

Posted: Sat May 05, 2018 1:56 pm
by KDJ
Chang

Missing BREAK in SEQUENCE. Try this:

Code: Select all

FUNCTION Main_List_1_OnChange()
  LOCAL bErrHandler
  LOCAL uResult
  LOCAL cEditValue

  LOCAL nValue := GetProperty( "Main", "List_1", "Value")
  LOCAL cDisplayItem := ALLTRIM( GetProperty( "Main", "List_1", "Item", nValue))
  // cDisplayItem := "getStartupFolder()"
  LOCAL cCode := "{|x| " + cDisplayItem + "}"

  bErrHandler := ErrorBlock({|| Break(NIL)})

  BEGIN SEQUENCE
    bCode := &cCode
    uResult := EVAL( bCode)
  RECOVER
    msgDebug( "undefined function :", cCode)  
  END 

  ErrorBlock(bErrHandler)

  IF VALTYPE( uResult) == 'C'
    cEditValue := uResult + HB_EOL() + GetProperty( "Main", "Edit_1", "Value")
    SetProperty( "Main", "Edit_1", "Value", cEditValue)
    msgDebug( cDisplayItem, uResult)
  ELSE
    msgDebug( uResult)
  ENDIF
  RETURN NIL

Re: Trap error with Begin Sequence

Posted: Sun May 06, 2018 6:25 am
by hmgchang
Thank you KDJ...
It works

:D

Next question :
Why is hb_dskspacd() not recognise as a build in function while hb_eol() works ?

Best rgds
chang

Re: Trap error with Begin Sequence

Posted: Sun May 06, 2018 12:20 pm
by KDJ
hmgchang wrote:
Sun May 06, 2018 6:25 am
Why is hb_dskspacd() not recognise as a build in function while hb_eol() works ?
Because HB_EOL() function is used in HMG code and HB_DiskSpace() function is nowhere used.
You need use REQUEST statement for this function, eg:

Code: Select all

#include <hmg.ch>

#define ZFMAIN Main
#define ZMFILE "&File"
#define ZMFILE01 "&Open"
#define ZSTTBAR01 "hfManager"

REQUEST HB_DiskSpace
REQUEST HB_BuildDate

FUNCTION Main()
...

Re: Trap error with Begin Sequence

Posted: Sun May 06, 2018 9:40 pm
by hmgchang
Thanks Sir,

in my case, should I REQUEST all available functions at the beginning of the program ?
or can I do the REQUEST at runtime ( when the function name is clicked/List onChange) ?

TIA

best rgds
Chang

Re: Trap error with Begin Sequence

Posted: Mon May 07, 2018 6:13 pm
by KDJ
hmgchang wrote:
Sun May 06, 2018 9:40 pm
in my case, should I REQUEST all available functions at the beginning of the program ?
Yes, all that will be called by the macro and are not explicitly used in the program code.
hmgchang wrote:
Sun May 06, 2018 9:40 pm
or can I do the REQUEST at runtime ( when the function name is clicked/List onChange) ?
No. REQUEST is an instruction for the linker.
Read here: http://www.itlnet.net/programming/progr ... 0da82.html

Re: Trap error with Begin Sequence

Posted: Wed May 09, 2018 11:00 pm
by hmgchang
Thank you very much Sir,
:D