Shop OBEX P1 Docs P2 Docs Learn Events
Stamp Editor feature — Parallax Forums

Stamp Editor feature

bobhillierbobhillier Posts: 27
edited 2006-04-16 19:20 in General Discussion
Perhaps this has been asked before....

Can a future upgrade to the Stamp Editor provide an include-file capability?

I'm doing multi-page programming and am constantly copying the "header" section of page 0 to all the other pages to ensure every page has the correct scratchpad, variable and constants layout. Programs behave very badly when one page does not have the same scratchpad, variable and constants structure as the rest of the pages.

Clever use of conditional compile could also result in strong and efficient support of multi-page page-flip code as well as other significant code re-use opportunities.

There are a multitude of ways that include files could improve and empower Stamp development.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Bob, Ottawa
W75 54 17·· N45 18 30
·········· G16 #27

Comments

  • NewzedNewzed Posts: 2,503
    edited 2004-08-19 16:37
    I do the same thing and I am quite comfortable with copy and paste.· This assures me that the header on page 0 is exactly replicated on all the other pages.· With any other procedure I would feel obliged to carefully check each header to make sure it was correct.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    4-digit serial LED

    http://hometown.aol.com/newzed/index.html
    ·
  • bobhillierbobhillier Posts: 27
    edited 2004-08-19 17:48
    Use of an include file guarantees every slot file has the same data since the include file is included by every slot file. Use of an include file is effectively, an automated "Copy and Paste". You write the code definitions once and·they are·automatically compiled/assembled into every other slot file.

    All the high level languages I've worked with support include files. It would be nice if Stamp did as well.

    "Somewhere.... over the rainbow...."


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······ Bob, Ottawa
    W75 54 17·· N45 18 30
    ·········· G16 #27
  • Harry StonerHarry Stoner Posts: 54
    edited 2004-08-19 18:07
    Bob, I asked about the same thing a couple of weeks ago. Include files encourage you to put effort into the setup once and then be able to re-use it. If a file change is required, it only needs to be changed once, and not in n spots.

    It doesn't affect the token code created so the impact of adding such a feature is isolated. I also think the concept of includes is simple enough to not scare newbies away.

    Hope it at least makes it onto a Parallax todo list!

    Harry
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-19 18:17
    bobhillier said...
    <snip>·Use of an include file is effectively, an automated "Copy and Paste". You write the code definitions once and·they are·automatically compiled/assembled into every other slot file.

    It's not that easy because the compiler is external and wants to flag a file if there's an error.· If you have an include file that just contains variable definitions, it won't compile.· So, what the BASIC Stamp editor would have to do is copy your include file into your source then save it to a new file to pass on to the compilation module.· But how do we flag an error then?· If you have an error in your definitions, how do we tell you?· Or in your code? -- because to get everything to compiler is has been merged into one file that is not your original source.

    We're not giving up ... I just wanted to point out that our compiler engineer has thought long and hard about this and adding include files is NOT as trivial as we would all like to believe.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Jeff MartinJeff Martin Posts: 760
    edited 2004-08-19 20:00
    Hi,

    Jon is correct.· I've thought long and hard about this issue and the complexities it entails as Jon noted.· I, too, am not giving up on it, but we had to make a decision during the last major overhaul of the tokenizer and editor about some very important items and the #INCLUDE feature had to be temporarily set aside.

    But, again, we have not given up on the request.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Jeff Martin

    · Sr. Software Engineer
    · Parallax, Inc.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2004-08-20 14:28
    If you are running Linux this isn't so much of a problem, as the opensource project for Linux (linked to on the parallax download site, allows you to pass the program in on stdin into the tokenizer. The effect this has is that to include a header all you have to do is link the "header" and the code with a pipes and cats and direct the output to the tokenizer. Since the error messages for the open source project already lack line number and other usefull information you're not losing much by doing this.

    In windows, I suppose it wouldn't be hard to write code that appends a given header where ever it finds a given a special comment of sorts in files, but this no more effecient than copy and paste because you'd have to leave the program to do it. I suppose a useful tool that anyone who knows a little C could put together is a program that checks a "header" file and checks code between two special comments ("'START HEADER" and "'END HEADER" for instance) if they don't match the header, replace the code in the section with the code in the header.

    something along the lines of (note this was written in haste and doesn't do some needed checks on streams and boundries and assumes some varibles you'd have to get from input or argc & argv):
    vector<string> headerVec;
    vector<string> sourceVec;
    string s;
    ifstream inHeader;
    inHeader.open(headerFileName.c_str());
    while(inHeader && !inHeader.eof()
    {
          getline(inHeader,s,'\n');
         headerVec.push_back(s);
    }
    inHeader.close();
    for(int i =0; i < num_files; ++i)
    {
      ifstream inSource;
      inSource.open(file[i].c_str());
       bool replace = false;
      while(inSource && !inSource.eof())
      {
         getline(inSource,s,'\n');
          if(s == "\'START HEADER")
          {
               replace = true;
                sourceVec.push_back("\'START HEADER");
               for(vector<string>::iterator iter = headerVec.begin(); iter != headerVec.end(); ++iter)
                {
                      sourceVec.push_back(*iter);
                }
                sourceVec.push_back("\'END HEADER");
          }
         else if(s == "\'END HEADER")
               replace = false;
          else if(!replace)
                sourceVec.push_back(s);
      }
      if(replace)
      {
            cerr << "No closeing header tag in file: " << file[i];
             inSource.close();
      }
      else
       {
           inSource.close();
           ofstream out Source;
           outSource.open(file[i].c_str());
           for(vector<string>::iterator iter = sourceVec.begin(); iter != sourceVec.end(); ++iter)
           {
                 outSource << *iter << '\n';
           }
       }
    }
    [/i][/i][/i]
    
  • daviddrakedaviddrake Posts: 20
    edited 2006-04-16 19:20
    I just wanted to let you know that this issue is still out there and it would be great if it could be supported. We use six banks and assuring that ALL cuts and pastes were done accurately is a slight headache. The development concerns listed above are a concern. What about a compromise... the main compelling reason for the include files is the variable definition process. Suppose you had a single global variable block defined in module zero, that would be reused only in the named files in the remaining set. In addition a local variable section could follow the global definition block, if needed. This would allow for inline checking and variable sharing without danger of variable misalignment. That would cover 90% of the need for includes. BTW we have deployed a commercial product with the OEM pe chipset with rave reviews. And congratulations on the Propeller!

    David Drake
    Hadronex
Sign In or Register to comment.