Announcement

Collapse
No announcement yet.

Structure like in c

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Structure like in c

    Hi,

    Does it exist a structure solution like in C or C++ ?

    Best Regards,
    Toragan

  • #2
    Hi Toragan,

    4DGL doesn't implement a structure solution similar to C or C++. May I know why you
    would want to apply it into your project? If you're having technical difficulties implementing
    4DGL's existing data structures, perhaps we could assist you on that.

    You could perhaps try to make arrays inside an array like suggested here on this thread:
    Arrays of arrays of string arrays post #7

    For more information regarding 4DGL, you may refer to the 4DGL Programmer's Reference Manual.
    https://4dsystems.com.au/mwdownloads...ad/link/id/17/

    I hope this helps. If you have other inquiries feel free to ask.

    Best regards,
    Sherwin

    Comment


    • #3
      Hi Sherwin,

      I think it's easier to read the code and to manipulate a lot of data and arrays with structure.

      For exemple I have many arrays:
      Code:
      #CONST
      var rowCleaning[12] := [3,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1];
      var rowWelding[12] := [21,22,17,23,-1,26,-1,-1,-1,-1,-1,25];
      var rowLiquid[12] := [13,14,2,15,16,-1,-1,-1,-1,-1,-1,-1];
      var rowSSDW[12] := [12,24,11,-1,-1,-1,-1,-1,-1,-1,-1,-1];
      var rowFrequency[12] := [7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
      var rowCycles[12] := [-1,-1,-1,-1,-1,9,-1,-1,-1,-1,-1,-1];
      var rowAmplitude[12] := [-1,-1,4,-1,-1,-1,-1,-1,-1,-1,-1,-1];
      var rowTime[12] := [-1,-1,-1,-1,-1,5,-1,-1,-1,-1,-1,-1];
      var rowStart[12] := [-1,-1,-1,-1,18,6,-1,-1,-1,-1,-1,-1];
      var rowStop[12] := [-1,-1,-1,28,27,19,-1,-1,-1,-1,-1,-1];
      var rowNrjMode[12] := [-1,-1,-1,30,-1,-1,8,9,-1,-1,-1,-1];
      var rowTimeMode[12] := [-1,-1,-1,-1,-1,31,-1,-1,32,33,-1,-1];
      var rowContinuousMode[12] := [-1,-1,-1,-1,-1,36,-1,-1,-1,-1,34,35];
      
      var pageArray[13] := [2, 8, 9, 10, 12, 13, 15, 16, 17, 18, 21, 22, 23];
      var digitArray[13] := [rowCleaning, rowWelding, rowLiquid, rowSSDW, rowFrequency, rowCycles, rowAmplitude, rowTime, rowStart, rowStop, rowNrjMode, rowTimeMode, rowContinuousMode];
      #END
      But can I do that ? :
      Code:
      #DATA
      word rowCleaning3, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1
      word rowWelding 21, 22, 17, 23, -1, 26, -1, -1, -1, -1, -1, 25
      word rowLiquid 13, 14, 2, 15, 16, -1, -1, -1, -1, -1, -1, -1
      word rowSSDW 12,24,11,-1,-1,-1,-1,-1,-1,-1,-1,-1
      word rowFrequency 7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
      word rowCycles[  -1,-1,-1,-1,-1,9,-1,-1,-1,-1,-1,-1
      word rowAmplitude -1,-1,4,-1,-1,-1,-1,-1,-1,-1,-1,-1
      word rowTime -1,-1,-1,-1,-1,5,-1,-1,-1,-1,-1,-1
      word rowStart -1,-1,-1,-1,18,6,-1,-1,-1,-1,-1,-1
      word rowStop -1,-1,-1,28,27,19,-1,-1,-1,-1,-1,-1
      word rowNrjMode -1,-1,-1,30,-1,-1,8,9,-1,-1,-1,-1
      word rowTimeMode  -1-1,-1,-1,-1,-1,31,-1,-1,32,33,-1,-1
      word rowContinuousMode -1,-1,-1,-1,-1,36,-1,-1,-1,-1,34,35
      
      word pageArray 2, 8, 9, 10, 12, 13, 15, 16, 17, 18, 21, 22, 23
      word digitArray rowCleaning, rowWelding, rowLiquid, rowSSDW, rowFrequency, rowCycles, rowAmplitude, rowTime, rowStart, rowStop, rowNrjMode, rowTimeMode, rowContinuousMode
      #END
      Ps: Can I get the size of an array ?

      Example:
      Code:
      for (idx := 0; idx < 12; idx++)
         . . .
      
      for (idx := 0; idx < size(digitArray); idx++)
         . . .
      Best regards
      Toragan
      Last edited by Toragan; 25 July 2019, 07:59 PM.

      Comment


      • #4
        Hi Toragan,

        Apology for the delayed response.

        To get the size of an array:
        Code:
        n := sizeof(arr);
        For you first block of code, you need to remove #CONST #END as the
        compiler will throw illegal use of 'var' error if you don't. Please do note that if you
        declare a data inside a #constant directive, the data value cannot be changed
        during run-time.
        Code:
        var rowCleaning[12] := [3,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1];
        var rowWelding[12] := [21,22,17,23,-1,26,-1,-1,-1,-1,-1,25];
        var rowLiquid[12] := [13,14,2,15,16,-1,-1,-1,-1,-1,-1,-1];
        var rowSSDW[12] := [12,24,11,-1,-1,-1,-1,-1,-1,-1,-1,-1];
        var rowFrequency[12] := [7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
        var rowCycles[12] := [-1,-1,-1,-1,-1,9,-1,-1,-1,-1,-1,-1];
        var rowAmplitude[12] := [-1,-1,4,-1,-1,-1,-1,-1,-1,-1,-1,-1];
        var rowTime[12] := [-1,-1,-1,-1,-1,5,-1,-1,-1,-1,-1,-1];
        var rowStart[12] := [-1,-1,-1,-1,18,6,-1,-1,-1,-1,-1,-1];
        var rowStop[12] := [-1,-1,-1,28,27,19,-1,-1,-1,-1,-1,-1];
        var rowNrjMode[12] := [-1,-1,-1,30,-1,-1,8,9,-1,-1,-1,-1];
        var rowTimeMode[12] := [-1,-1,-1,-1,-1,31,-1,-1,32,33,-1,-1];
        var rowContinuousMode[12] := [-1,-1,-1,-1,-1,36,-1,-1,-1,-1,34,35];
        
        var pageArray[13] := [2, 8, 9, 10, 12, 13, 15, 16, 17, 18, 21, 22, 23];
        var digitArray[13] := [rowCleaning, rowWelding, rowLiquid, rowSSDW, rowFrequency, rowCycles, rowAmplitude, rowTime, rowStart, rowStop, rowNrjMode, rowTimeMode, rowContinuousMode];
        For the second block of code, please keep mind that "#DATA blocks resides in the CODE space and cannot
        be changed during run-time (i.e. it is read only)". (4DGL Programmer's Reference Manual page 14)

        I do hope this information gives you some clarity.

        Good luck and best regards,
        Sherwin

        Comment


        • #5
          Hi Sherwin,

          Thanks, I probably was tired but "sizeof" seems logical.

          And I had the surprise when I tried to compile with #CONST #END but my project works well at this moment.

          Best regards
          Toragan
          Last edited by Toragan; 29 July 2019, 08:18 PM.

          Comment


          • #6
            Hi Toragan,

            No worries, happy to help.

            Glad to know that you're project is going well.

            Best regards,
            Sherwin

            Comment

            Working...
            X