Check for null pointer

paulpotat
2021-05-19
2021-05-19
  • paulpotat

    paulpotat - 2021-05-19

    Hello,
    I would like to check for the validity of a pointer in CodeSys but I can't find how to do that anywhere...

    How could I do that ? I would like to be able to do something like that :

    IF myPointer = NULL THEN
    ...
    

    I found this (https://help.codesys.com/api-content/2/codesys/3.5.12.0/en/_cds_obj_pou_checkpointer/) in the documentation but I don't understand how I'm supposed to use that.

    Hoping somebody can help me, have a good day !

     
  • hermsen

    hermsen - 2021-05-19

    IF pThePointer <> 0 THEN
    // Pointer contains an adres
    xValid := TRUE;
    ELSE
    // Pointer does not contain an adres
    xValid := FALSE;
    END_IF;

     
    πŸ‘
    2
  • paulpotat

    paulpotat - 2021-05-19

    Thank you very much !

     

Log in to post a comment.