• YDB-E-DEVPARUNK

    From Luciano Muratore@21:1/5 to All on Mon Jan 3 05:00:45 2022
    Dears,
    I am trying to implement the program from: https://www.youtube.com/watch?v=ObUAklaia1Y.
    But, I have the following problem:
    open 1:"mtrees2003.m,old"
    ^-----
    At column 9, line 2, source module /home/test/.yottadb/r1.32_x86_64/r/mesh.m
    %YDB-E-DEVPARUNK, Deviceparameter unknown

    The code was:
    kill ^mesh
    open 1:"mtrees.m,old"
    if '$test write "mtrees2003.m not found",in,! halt

    Any suggestions?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From K.S. Bhaskar@21:1/5 to Luciano Muratore on Mon Jan 3 06:25:47 2022
    On Monday, January 3, 2022 at 8:00:46 AM UTC-5, Luciano Muratore wrote:
    Dears,
    I am trying to implement the program from: https://www.youtube.com/watch?v=ObUAklaia1Y.
    But, I have the following problem:
    open 1:"mtrees2003.m,old"
    ^-----
    At column 9, line 2, source module /home/test/.yottadb/r1.32_x86_64/r/mesh.m %YDB-E-DEVPARUNK, Deviceparameter unknown

    The code was:
    kill ^mesh
    open 1:"mtrees.m,old"
    if '$test write "mtrees2003.m not found",in,! halt

    Any suggestions?

    That does not look like YottaDB code. Device parameters in M are not standard. https://docs.yottadb.com/ProgrammersGuide/ioproc.html# and https://docs.yottadb.com/ProgrammersGuide/commands.html may be helpful.

    Regards
    – Bhaskar

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ed de moel@21:1/5 to All on Mon Jan 3 07:29:07 2022
    The example on youtube uses Kevin O'Kane's implementation of M[UMPS].
    The YottaDB equivalent of that open statement would be OPEN "mtrees2003.txt":READONLY
    and later on in the program, the USE and CLOSE commands should not use "unit number 1", but "mtrees2003.txt".
    The "use 5" in that sample would probably become "USE $Principal".
    Of course, that would require that the file named mtrees2003.txt exists on the computer where the program is running...
    Ed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jens@21:1/5 to All on Mon Jan 3 07:48:14 2022
    A yottadb-version of this code shoul look like:
    Meshtree ;Meshtree.m
    kill ^mesh
    set device="mtrees2003.txt"
    open device:(readonly:exception="W device_"" not found"" halt")
    for use device quit:$zeof read a do
    . set key=$piece(a,";",1) ; text description
    . set code=$piece(a,";",2) ; everything else
    . if key=""!(code="") quit
    . for i=1:1 do
    . . set x(i)=$piece(code,".",i) ; extract code numbers
    . . if x(i)="" quit
    . set i=i-1
    . use 0
    . set z="^mesh(" ; begin building a global reference
    .;
    .;-----------------------------------------------------------------------
    .; build a reference like ^mesh("A01","047","025","600)
    .; by concatenating quotes, codes, quotes, and commas onto z
    .;#-----------------------------------------------------------------------
    .;
    . for j=1:1:i-1 set z=z_""""_x(j)_""","
    . set z="set "_z_""""_x(i)_""")="""_key_""""
    .;
    .;#-----------------------------------------------------------------------
    .;# z now looks like set ^mesh("A01","047")="Abdomen"
    .;# now execute the text
    .;#-----------------------------------------------------------------------
    .;
    . write z,!
    . xecute z
    ;
    close device
    use 0
    write "done",!
    halt

    Remember the double spaces after argumentless for and argumentless quit...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ed de moel@21:1/5 to All on Mon Jan 3 09:40:23 2022
    Since this code was intended as a teaching example, I'd change it for the following reasons:
    - use meaningful variable names
    - do not use single character variable names
    - do not use HALT unless there is a severe error, use QUIT to go back to the calling program
    - use the USE command close to the READ or WRITE that it is associated with
    - do not use unnecessary intermediate arrays
    - do not use multiple loops when a single one is all you need
    - I just prefer to use $Principal rather than a platform-specific device number, although both work the same in all implementations that I know of
    Which gives me:
    Meshtree ;
      kill ^mesh
      set filename="mtrees2003.txt"
      open filename:(readonly:exception="write "_filename_"" not found"" halt")
      for  use filename quit:$zeof  read line do
      . set key=$piece(line,";",1) ; text description
      . set code=$piece(line,";",2) ; list of codes
      . if (key="")!(code="") quit
      . set command="Set ^mesh",separator="("
      . for ii=1:1 Set part=$piece(code,".",ii) Quit:part=""  Set command=command_separator_""""_part_"""",separator=","
      . set command=command_")="""_key_""""
      .;
      .;#-----------------------------------------------------------------------   .;# command now looks like set ^mesh("A01","047")="Abdomen"
      .;# now execute the text
      .;#-----------------------------------------------------------------------   .;
      . use $principal write command,!
      . xecute command
      ;
      close filename
      use $principal write "done",!
      quit

    (And of course, the code assumes that neither the mesh-codes, nor the key values contain any occurrences of the character " (quote, sometimes called double quote)...)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ed de moel@21:1/5 to ed de moel on Wed Jan 5 15:10:39 2022
    On Monday, January 3, 2022 at 12:40:24 PM UTC-5, ed de moel wrote:
    Since this code was intended as a teaching example, I'd change it for the following reasons:
    - use meaningful variable names
    - do not use single character variable names
    - do not use HALT unless there is a severe error, use QUIT to go back to the calling program
    - use the USE command close to the READ or WRITE that it is associated with
    - do not use unnecessary intermediate arrays
    - do not use multiple loops when a single one is all you need
    - I just prefer to use $Principal rather than a platform-specific device number, although both work the same in all implementations that I know of
    Which gives me:
    Meshtree ;
    kill ^mesh
    set filename="mtrees2003.txt"
    open filename:(readonly:exception="write "_filename_"" not found"" halt")
    for use filename quit:$zeof read line do
    . set key=$piece(line,";",1) ; text description
    . set code=$piece(line,";",2) ; list of codes
    . if (key="")!(code="") quit
    . set command="Set ^mesh",separator="("
    . for ii=1:1 Set part=$piece(code,".",ii) Quit:part="" Set command=command_separator_""""_part_"""",separator=","
    . set command=command_")="""_key_""""
    .;
    .;#-----------------------------------------------------------------------
    .;# command now looks like set ^mesh("A01","047")="Abdomen"
    .;# now execute the text
    .;#-----------------------------------------------------------------------
    .;
    . use $principal write command,!
    . xecute command
    ;
    close filename
    use $principal write "done",!
    quit

    (And of course, the code assumes that neither the mesh-codes, nor the key values contain any occurrences of the character " (quote, sometimes called double quote)...)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ed de moel@21:1/5 to All on Wed Jan 5 15:13:23 2022
    For some reason this exercise interests me.
    If you don't have the file mtrees2003.txt, I made the current version available at
    http://71.174.62.16/mtrees2022.txt
    And, of course, I still leave it as a home-work assignment for the students to handle key values and code values that contain a quote character (it's not that hard).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)