Trap error with Begin Sequence

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 239
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Trap error with Begin Sequence

Post by hmgchang » Fri May 04, 2018 9:38 pm

Dear Friends,

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

best rgds,
Chang
Just Hmg It !

KDJ
Posts: 202
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 227 times

Post by KDJ » Sat May 05, 2018 1:56 pm

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: 239
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Sun May 06, 2018 6:25 am

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: 202
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 227 times

Post by KDJ » Sun May 06, 2018 12:20 pm

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: 239
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Sun May 06, 2018 9:40 pm

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: 202
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 227 times

Post by KDJ » Mon May 07, 2018 6:13 pm

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: 239
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Wed May 09, 2018 11:00 pm

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

Post Reply