Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

YDB-E-DEVPARUNK

75 views
Skip to first unread message

Luciano Muratore

unread,
Jan 3, 2022, 8:00:46 AM1/3/22
to
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?



K.S. Bhaskar

unread,
Jan 3, 2022, 9:25:48 AM1/3/22
to
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

ed de moel

unread,
Jan 3, 2022, 10:29:08 AM1/3/22
to

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

Jens

unread,
Jan 3, 2022, 10:48:15 AM1/3/22
to
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...

ed de moel

unread,
Jan 3, 2022, 12:40:24 PM1/3/22
to
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)...)
Message has been deleted

ed de moel

unread,
Jan 5, 2022, 6:13:24 PM1/5/22
to
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).
0 new messages