General Discussion & Announcements

 View Only
Expand all | Collapse all

Key Words / variable names

  • 1.  Key Words / variable names

    Posted 02-28-2023 13:47

    Hi All,

    I'm sure I've posted on this matter before but I just had a bit of a wobble understanding why my code wouldn't compile, until I notice the variable I had used started with the word NEXT (as in Next_Available) and the D3 compile went out and took another shot of tequila and said 'nada - not today hombre'

    So, just put it out there NEXT (suffix not allowed) and I'm sure there may be others - like NOT and FOR and ...

    Does anyone care to comment?



    ------------------------------
    Stefano Gallotta
    Managing Member
    Simply Red Open Systems
    Milnerton ZA
    ------------------------------


  • 2.  RE: Key Words / variable names

    Posted 03-01-2023 10:15

    Greetings fellow uni verse inhabitants,

    I recent encountered a sistuation similar to this where a column had been named "From" and where asking for the data it interpreted it as a copy operation.

    not good.



    ------------------------------
    David Byrd
    Chief Engineer
    Brooks Equipment
    Charlotte NC US
    ------------------------------



  • 3.  RE: Key Words / variable names

    PARTNER
    Posted 03-01-2023 10:15

    Hello,

    We never used "_" in our programs. We use "." to separate words in variables and we never had a problem. Probably someone 40 years ago found out that, and put it in our standards. :)

    On another hand, I don't recall any programming language to treat "_" as a space.

    Regards,

    Chris



    ------------------------------
    Chris Wolcz
    Senior Software Developer
    Execontrol Global Solutions
    Clifton Park NY US
    ------------------------------



  • 4.  RE: Key Words / variable names

    PARTNER
    Posted 03-02-2023 08:52

    Hi, 

    Given there are hundreds, if not thousands, of different programming languages out there. What language are you talking about ?



    ------------------------------
    Gary Freestone
    Systems Programmer
    Kyndryl Inc
    Mt Helen VIC AU
    ------------------------------



  • 5.  RE: Key Words / variable names

    PARTNER
    Posted 03-06-2023 08:34

    Pick BASIC

    This is a Rocket Software community discussion board so we are almost always talking about Pick BASIC.



    ------------------------------
    James Carthew
    Application Specialist
    LRS Health Pty Ltd
    Heidelberg VIC AU
    ------------------------------



  • 6.  RE: Key Words / variable names

    Posted 03-02-2023 08:52

    Maybe something to do with SQL where an underscore is used as wildcard for one character?



    ------------------------------
    Ed Van Hees
    Senior Consultant
    Rocket Forum Shared Account
    ------------------------------



  • 7.  RE: Key Words / variable names

    Posted 03-02-2023 08:52

    Yup, I've seen some doozies in my day - my favorite was using a variable named 'Debug' - the coder had a line in their program that said 'IF DEBUG THEN DEBUG'.  It worked, but YUCK!



    ------------------------------
    Kathleen Hambrick
    Programmer at Colwell
    ------------------------------



  • 8.  RE: Key Words / variable names

    ROCKETEER
    Posted 03-03-2023 16:27

    What's wrong with that?  Of course, it helps if you have standards and use upper/lower case consistently as part of those standards.  In my personal stuff on my own PC, in REXX:  "If debug Then..."  In perl, "if $debug" seems quite clear.  Or sometimes the variable is dbg / $dbg if I'm being lazy.

    I wish PL/I was more widely used.  Then I could code:  IF WRITE THEN WRITE ... .  That would cause a FORTRAN compiler to have a heart attack.



    ------------------------------
    Leonard Woren
    Senior Software Engineer
    Rocket Internal - All Brands
    CA US
    ------------------------------



  • 9.  RE: Key Words / variable names

    Posted 03-06-2023 09:08

    There are a lot of things wrong with 'If debug then debug' - the most obvious being maintainability. If you were the sole architect on a system, and you had the foresight to use that line and concept every single place you wanted the program to call the debugger - maybe I would agree its a plausable idea. But this is PICK - I know of no place that has only had one coder. Additionally, *most reserved words cannot be used as variables - which is how this thread started, so doing so is risky. It also brings in an additional level of confusion. I don't like to have to follow variables to know what they are - there is increased and efficient maintainability in code that uses appropriate language. In this case you are making a flag, so I personally would use 

    IF DEBUG.FLG THEN DEBUG

    Just my opinion after almost 40 years of maintaining other people's code.



    ------------------------------
    Kathleen Hambrick
    Programmer at Colwell
    ------------------------------



  • 10.  RE: Key Words / variable names

    Posted 03-07-2023 09:30

    I take my variable names a step further.  All my variable names are uniquely searchable.  The names are completely unique and do not contain portions of other variable names or reserved words or commands.  I don't want to search for variable REC and get hits on CUST.REC, so REC as a name is not unique enough.  It also isn't very meaningful from a maintainability standpoint.  So for me, the IF DEBUG.FLG THEN DEBUG would not fly.  I'd use IF DBUG.FLG THEN DEBUG.



    ------------------------------
    DEAN ARMBRUSTER
    Developer V
    Ferguson Enterprises
    Newport News VA US
    ------------------------------



  • 11.  RE: Key Words / variable names

    Posted 03-06-2023 11:16

    Yes when coding for oneself, something systems programmers tend to do constantly, it's ok to use any convention you wish.

    Speaking for those of us who have to support and extend that coding, I would suggest coding for complete transparency, should be the goal.



    ------------------------------
    Will Johnson
    Systems Analyst
    Rocket Forum Shared Account
    ------------------------------



  • 12.  RE: Key Words / variable names

    Posted 03-06-2023 15:43

    In my 30 year PICK / Universe programming career I write code so that it can be read like a book and easily followed by the next person who will be called to modify it. If that happens with comments in crucial places, not much documentation is necessary as to what the code is doing.

    The "IF DEBUG..."  use is 1. confusing and 2. Harder for the next person to understand than "IF REQ.DEBUGGING THEN DEBUG".  Goes along the lines of using the GO statement all over the code, making it harder to follow.

    That's my 2-cent worth



    ------------------------------
    Jack Garivaldis
    Development Mgr
    Intercontinental Exchange Inc
    Atlanta GA US
    ------------------------------



  • 13.  RE: Key Words / variable names

    Posted 03-07-2023 08:24

    Hi Kathleen, 

      I also think that DEBUG as a variable is totally inadequate. But the technique of having a debug flag to activate in certain conditions is good, for example, when you have to debug particular cases of a big billing program. In that cases, what we do is to have a set of debug flags, and even with counters, so you can debug certain number of cases and then let the program run.

      You set up, for example, three debug flags, as:

      debFlag1 = 5

      debFlag2 = 8

      debFlag3 = 1

      Then, in the branches of the code you want to watch, you place:

      if debFlag1 then 

         debug

         debFlag1 -= 1

      end 

        And so on. So, in the example, debFlag1 will fall into the debugger up to 5 times, debFlag2 up to 8, and debFlag1 just once, and then the program will run through without stopping. 

       Saludos,



    ------------------------------
    Enrique Ignacio Murphy
    Software Engineer
    Aleator SRL
    Argentina
    ------------------------------



  • 14.  RE: Key Words / variable names

    Posted 03-07-2023 09:02

    Absolutely! The writer clearly intended to create a debug flag, which makes great sense. However using a command name as a variable name is unwise, for a number of reasons. Maintainability goes way down, wasting time trying to figure out why your code doesn't compile or work properly would be another. Some words can be used as variable names even though they mean something entirely else as well, but not all. Makes me think of Jurassic Park - just because you CAN do something doesn't mean you SHOULD.



    ------------------------------
    Kathleen Hambrick
    Programmer at Colwell
    ------------------------------



  • 15.  RE: Key Words / variable names

    Posted 03-02-2023 08:52

    I saw code where someone used a command as a variable:

    IF DEBUG THEN DEBUG

    yuck!



    ------------------------------
    Kathleen Hambrick
    Programmer at Colwell
    ------------------------------



  • 16.  RE: Key Words / variable names

    Posted 03-23-2023 20:57

    Interestingly in UV basic, from at least UV8.3.3 it appears that the "next variable" is optional. From my 8.3.3 quick reference: NEXT  [ variable ]

    The following code is valid in UV11.3.4 too: for i = 1 to 10 ; crt i ; next

    I would think though that nested for/next loops would require the variable to be specified against its respective next statement.

    Cheers,
    Peter



    ------------------------------
    Peter Cheney
    Developer and Systems Superstar
    Firstmac
    Brisbane Qld Australia
    ------------------------------