UserTech : SETVAR not working for struc field of type STRING (CHAR[]) in KFDc

  • Hello,


    KRC2, KSS5.6, KR5002MT + track KL1500-3 + turntable


    I've been successfully using UserTech KFD files to get custom menus. However, I have an error when trying to write (with a script) to a STRING (CHAR[]) field of a custom STRUC.


    This is how my STRUC is defined :


    Code
    DEFDAT MdiManager PUBLIC
    
    
    	GLOBAL STRUC MDIACTION_T CHAR Module[8], INT ID, MDICONTEXT_T Context, BOOL AutoQuit
    	DECL GLOBAL MDIACTION_T requestedAction = {ID 0, Module[] " "}
    
    
    ENDDAT


    I can change the ID (INT) field by mean of this script :


    Code
    DEFSCRIPT NewMDI_2001
    	SETVAR(FULLPATH[] "requestedAction.ID", VALUE[] "2001")
    ENDSCRIPT


    But neither of these script will work on the field Module[] (String) :


    Code
    DEFSCRIPT NewMDI_2001
    	SETVAR(FULLPATH[] "requestedAction.Module[]", VALUE[] "CELL")
    ENDSCRIPT
    DEFSCRIPT NewMDI_2003
    	SETVAR(FULLPATH[] "requestedAction.Module", VALUE[] "CELL")
    ENDSCRIPT
    DEFSCRIPT NewMDI_2004
    	SETVAR(FULLPATH[] "MdiManager/requestedAction.Module[]", VALUE[] "CELL")
    ENDSCRIPT


    So my question are :



      • Is it possible to set string fields through SETVAR in KFD scripts ?

      • What is the proper syntax for FULLPATH[] ? Is it documented somewhere ?


    Thanks,


  • So my question are :



      • Is it possible to set string fields through SETVAR in KFD scripts ?

      • What is the proper syntax for FULLPATH[] ? Is it documented somewhere ?



    * yes it is
    * you already used it successfully so you should know correct syntax

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • [size=1em]first of all, UserTech is not another (independent) programming language... Kuka robots are programmed in KRL and ultimately that is what always need to be kept in mind. [/size][size=1em]UserTech has own syntax but... everything you want to do in a script, still need to be intact and match what KRL expects. I m talking about variable names and values. if you cannot use them correctly in KRL, you will not be able to use them in UserTech.[/size]



    [size=1em]For example you used:[/size]


    Quote
    Code
    SETVAR(FULLPATH[] "requestedAction.ID", VALUE[] "2001")



    [size=1em]that works because it correctly uses names and values that KRL expects. In KRL you could do the same with following line:
    [/size]

    Code
    requestedAction.ID = 2001



    [size=1em]NOTE:
    * Whatever variable name and value works in KRL, it need to be surrounded by quotation marks when it is used in KFD scripts. always
    * If something in KRL needs quotations, those quotations do not disappear just because you need to use this in a KFD scripts. they are still needed - always[/size]
    [size=1em]
    basically in KRL you could do:
    [/size]

    Code
    requestedAction.Module[]="CELL"



    [size=1em]therefore equivalent KFD script should be [/size]

    Quote
    Code
    SETVAR(FULLPATH[] "requestedAction.Module[]", VALUE[] ""CELL"")


    [size=1em]but... take a closer look at ""CELL'""[/size]



    [size=1em]this will create a conflict with UserTech syntax since it does not understand the difference - quotations look like quotations.[/size] [size=1em]that's the thing with computers, they need programmers to tell them what to do and how to interpret things. Without programmers influence UserTech would simply expect that first pair of quotations before CELL are important (and see them as an empty string value). Rest would be unexpected and considered superfluous (CELL"").[/size]


    [size=1em]it is programmers job to inform UserTech that outer pair of quotations are the "normal pair" and those outer quotations will stay "as is".[/size]



    [size=1em]but those inner quotations are not to be parsed or interpreted by UserTech, they are not for UserTech - they are needed by KRL.[/size]


    [size=1em]in other words from UserTech perspective they are special characters that need to be there but should be ignored (not treated as UserTech quotation). [/size]


    [size=1em]According to UserTech manual, this is done by placing forward-slash before each of them,[/size] [size=1em]so the final version is:[/size]

    Quote
    Code
    SETVAR(FULLPATH[] "requestedAction.Module[]", VALUE[] "/"CELL/"")

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

    Edited once, last by panic mode ().

  • Thank you for this clarification !


    It is much more clear to me now and I understand the logic of escaping the double quote in the KFD.
    I've been reading the manual several times before asking but I must say it's quite "smoggy".

  • Still struggling with this ...
    Now I want to have a softkey with the following label : "Butée >|". "|" is a valid ASCII character.


    The "|" character is not displayed and leads to a blank softkey (kicking out the last softkey I defined). Escaping like this "Butée >/|" does not work either.


    EDIT : the syntax "/|" seems to be reserved for parametrized output ...


    Quote

    In the case of parameterized outputs, the parameters must be tagged on to the key, separated by the characters "/|". The translated text and the parameters are then combined in the language database.


    Any idea to achieve this ?


Advertising from our partners