Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Temporary frame

    Dear All,

    if a data frame is created with a temporary name it is disposed of after the end of the program, ok.
    If it happens to be the current frame when it is disposed of, which frame will become active afterwards?
    • first one alphabetically?
    • first one historically?
    • last active still existing?
    • active at entry to program?
    • random?
    • ...something else?
    Thank you, Sergiy

  • #2
    Can't find any documentation, but the empirical approach suggests that it returns to the frame named "default" and if you have previously renamed that frame, it creates a new frame named "default".

    Note also that the section of the frames into on ado programming shows a technique for writing a program that will always - regardless of the outcome of the code - return to the frame from within which it was called.

    Code:
    . frames dir
      default  0 x 0
    
    . frame
      (current frame is default)
    
    . frame create a
    
    . frame change a
    
    . program define tryit
      1. tempname fx
      2. display "inside tryit"
      3. frame create `fx'
      4. frame change `fx'
      5. frames dir
      6. frame
      7. end
    
    . // "before tryit #1"
    . frames dir
      a        0 x 0
      default  0 x 0
    
    . frame
      (current frame is a)
    
    . tryit
    inside tryit
      __000000  0 x 0
      a         0 x 0
      default   0 x 0
      (current frame is __000000)
    
    . // "after tryit #1"
    . frames dir
      a        0 x 0
      default  0 x 0
    
    . frame
      (current frame is default)
    
    . frame rename default gnxl
    
    . // "before tryit #2"
    . frames dir
      a     0 x 0
      gnxl  0 x 0
    
    . frame
      (current frame is gnxl)
    
    . tryit
    inside tryit
      __000000  0 x 0
      a         0 x 0
      gnxl      0 x 0
      (current frame is __000000)
    
    . // "after tryit #2"
    . frames dir
      a        0 x 0
      default  0 x 0
      gnxl     0 x 0
    
    . frame
      (current frame is default)
    
    .

    Comment


    • #3
      Dear William,

      it creates a new frame named "default".
      this is unexpected! Of all the possibilities, I didn't expect this behavior.

      the section of the frames into on ado programming shows a technique for writing a program that will always - regardless of the outcome of the code
      Could you please provide a link to online documentation? I am not sure which section you refer to. At the moment I am using a pwf in combination with capture for this purpose.

      Also, another related question is: Is there any situation under which the frame creation may fail? What would that be? What are the relevant error codes? Any limit on the number of frames? What is the overhead created for each frame? (roughly, a few bytes, or megabytes?)

      Thank you, Sergiy

      Comment


      • #4
        The documentation I referred to is in
        Code:
        help frames_intro##ado
        and in the "frames intro" section of [D] The Stata Data Management Reference Manual PDF linked to from the top of that help file, as well as online at https://www.stata.com/manuals/dframesintro.pdf.

        That exhausts my knowledge of this subject. The technical questions would seem best addressed by Stata Technical Services. There don't seem to be any blog posts discussing the behind-the-scenes implementation details, although Carl Huber did post https://blog.stata.com/2019/09/06/fun-with-frames/ documenting some of his experiences.

        Comment

        Working...
        X