Trap error with Begin Sequence

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Trap error with Begin Sequence

Post by hmgchang »

Dear Friends,

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

best rgds,
Chang
Just Hmg It !
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Trap error with Begin Sequence

Post 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
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Trap error with Begin Sequence

Post 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
Just Hmg It !
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Trap error with Begin Sequence

Post 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()
...
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Trap error with Begin Sequence

Post 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
Just Hmg It !
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Trap error with Begin Sequence

Post 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
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Trap error with Begin Sequence

Post by hmgchang »

Thank you very much Sir,
:D
Just Hmg It !
Post Reply