Read/Write Matrix Encoded - Using 5X5 matrix

Share your advanced PureBasic knowledge/code with the community.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Read/Write Matrix Encoded - Using 5X5 matrix

Post by StarBootics »

Hello everyone,

A little code snippet just for the fun a Read and Write Matrix Encoded string using a very old school way to do it.
Using Matrix and Vector product.

Best regards
StarBootics

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Read/Write MatrixEncoded
; File Name : Read-Write Matrix55 Encoded.pb
; File version: 1.0.1
; Programming : OK
; Programmed by : StarBootics
; Date : 19-01-2016
; Last Update : 12-04-2016
; PureBasic code : V5.42 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Old encoding technics using 5X5 matrix and 
; vector.
; 
; All other types are supported as well but they
; are converted to longer string then they are
; encoded.
;
; This code is free to be use where ever you like 
; but you use it at your own risk.
;
; The author can in no way be held responsible 
; for data loss, damage or other annoying 
; situations that may occur.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

DeclareModule MatrixEncoded
  
  Declare ME_WriteString(FileID.l, String.s)
  Declare ME_WriteAsciiCharacter(FileID.l, Number.a)
  Declare ME_WriteUnicodeCharacter(FileID.l, Number.u)
  Declare ME_WriteByte(FileID.l, Number.b)
  Declare ME_WriteWord(FileID.l, Number.w)
  Declare ME_WriteCharacter(FileID.l, Number.c)
  Declare ME_WriteLong(FileID.l, Number.l)
  Declare ME_WriteInteger(FileID.l, Number.i)
  Declare ME_WriteQuad(FileID.l, Number.q)
  Declare ME_WriteFloat(FileID.l, Number.f)
  Declare ME_WriteDouble(FileID.l, Number.d)
  
  Declare.s ME_ReadString(FileID.l)
  Declare.b ME_ReadByte(FileID.l)
  Declare.a ME_ReadAsciiCharacter(FileID.l)
  Declare.w ME_ReadWord(FileID.l)
  Declare.c ME_ReadCharacter(FileID.l)
  Declare.u ME_ReadUnicodeCharacter(FileID.l)
  Declare.i ME_ReadInteger(FileID.l)
  Declare.l ME_ReadLong(FileID.l)
  Declare.q ME_ReadQuad(FileID.l)
  Declare.f ME_ReadFloat(FileID.l)
  Declare.d ME_ReadDouble(FileID.l)
  
EndDeclareModule

Module MatrixEncoded
  
  Structure Vector5Q
    
    i.q
    j.q
    k.q
    l.q
    m.q
    
  EndStructure
  
  Structure Matrix55Q
    
    e11.q
    e21.q
    e31.q
    e41.q
    e51.q
    e12.q
    e22.q
    e32.q
    e42.q
    e52.q
    e13.q
    e23.q
    e33.q
    e43.q
    e53.q
    e14.q
    e24.q
    e34.q
    e44.q
    e54.q
    e15.q
    e25.q
    e35.q
    e45.q
    e55.q
    
  EndStructure
  
  Macro SetLine1(Matrix55A, P_e11, P_e12, P_e13, P_e14, P_e15)
    
    Matrix55A\e11 = P_e11
    Matrix55A\e12 = P_e12
    Matrix55A\e13 = P_e13
    Matrix55A\e14 = P_e14
    Matrix55A\e15 = P_e15
    
  EndMacro
  
  Macro SetLine2(Matrix55A, P_e21, P_e22, P_e23, P_e24, P_e25)
    
    Matrix55A\e21 = P_e21
    Matrix55A\e22 = P_e22
    Matrix55A\e23 = P_e23
    Matrix55A\e24 = P_e24
    Matrix55A\e25 = P_e25
    
  EndMacro
  
  Macro SetLine3(Matrix55A, P_e31, P_e32, P_e33, P_e34, P_e35)
    
    Matrix55A\e31 = P_e31
    Matrix55A\e32 = P_e32
    Matrix55A\e33 = P_e33
    Matrix55A\e34 = P_e34
    Matrix55A\e35 = P_e35
    
  EndMacro
  
  Macro SetLine4(Matrix55A, P_e41, P_e42, P_e43, P_e44, P_e45)
    
    Matrix55A\e41 = P_e41
    Matrix55A\e42 = P_e42
    Matrix55A\e43 = P_e43
    Matrix55A\e44 = P_e44
    Matrix55A\e45 = P_e45
    
  EndMacro
  
  Macro SetLine5(Matrix55A, P_e51, P_e52, P_e53, P_e54, P_e55)
    
    Matrix55A\e51 = P_e51
    Matrix55A\e52 = P_e52
    Matrix55A\e53 = P_e53
    Matrix55A\e54 = P_e54
    Matrix55A\e55 = P_e55
    
  EndMacro
  
  Macro Product(VectorR, MatrixA, VectorB)
    
    VectorR\i = MatrixA\e11 * VectorB\i + MatrixA\e12 * VectorB\j + MatrixA\e13 * VectorB\k + MatrixA\e14 * VectorB\l + MatrixA\e15 * VectorB\m
    VectorR\j = MatrixA\e21 * VectorB\i + MatrixA\e22 * VectorB\j + MatrixA\e23 * VectorB\k + MatrixA\e24 * VectorB\l + MatrixA\e25 * VectorB\m
    VectorR\k = MatrixA\e31 * VectorB\i + MatrixA\e32 * VectorB\j + MatrixA\e33 * VectorB\k + MatrixA\e34 * VectorB\l + MatrixA\e35 * VectorB\m
    VectorR\l = MatrixA\e41 * VectorB\i + MatrixA\e42 * VectorB\j + MatrixA\e43 * VectorB\k + MatrixA\e44 * VectorB\l + MatrixA\e45 * VectorB\m
    VectorR\m = MatrixA\e51 * VectorB\i + MatrixA\e52 * VectorB\j + MatrixA\e53 * VectorB\k + MatrixA\e54 * VectorB\l + MatrixA\e55 * VectorB\m
    
  EndMacro
  
  ; <<<<<<<<<<<<<<<<<<<<<<
  ; <<<<< ReadString <<<<<
  
  Procedure.s ME_ReadString(FileID.l)
    
    Protected Inverse.Matrix55Q, VectorCoded.Vector5Q, VectorDecoded.Vector5Q
    
    MatrixID.b = ReadByte(FileID)
    
    Select MatrixID
        
      Case 0
        SetLine1(Inverse, -35, 110, -27, -29, 41)
        SetLine2(Inverse, 49, -155, 38, 41, -58)
        SetLine3(Inverse, 166, -523, 126, 137, -194)
        SetLine4(Inverse, 58, -183, 44, 48, -68)
        SetLine5(Inverse, -12, 38, -9, -10, 14)
        
      Case 1
        SetLine1(Inverse, -845, -198, -825, 285, -6)
        SetLine2(Inverse, -1263, -296, -1233, 426, -9)
        SetLine3(Inverse, 1565, 367, 1528, -528, 11)
        SetLine4(Inverse, 2116, 496, 2066, -714, 15)
        SetLine5(Inverse, 385, 90, 376, -130, 3)
        
      Case 2 
        SetLine1(Inverse, 2024, 154, 715, -1097, -2575)
        SetLine2(Inverse, -382, -29, -135, 207, 486)
        SetLine3(Inverse, 6502, 495, 2297, -3524, -8272)
        SetLine4(Inverse, -4059, -309, -1434, 2200, 5164)
        SetLine5(Inverse, -4716, -359, -1666, 2556, 6000)
        
      Case 3
        SetLine1(Inverse, 3674, 3438, -498, -371, 423)
        SetLine2(Inverse, -60, -56, 8, 6, -7)
        SetLine3(Inverse, 1336, 1250, -181, -135, 154)
        SetLine4(Inverse, 921, 862, -125, -93, 106)
        SetLine5(Inverse, 140, 131, -19, -14, 16)
        
      Case 4 
        SetLine1(Inverse, 9,  398,  -908,  464,  393)
        SetLine2(Inverse, -9,  -399,  910,  -465,  -394)
        SetLine3(Inverse, 2,  95,  -217,  111,  94)
        SetLine4(Inverse, 0,  16,  -37,  19,  16)
        SetLine5(Inverse, 7,  314,  -716,  366,  310)
        
      Case 5
        SetLine1(Inverse, 174,  291,  -91,  107,  -158)
        SetLine2(Inverse, -321,  -538,  168,  -198,  292)
        SetLine3(Inverse, 717,  1201,  -375,  442,  -652)
        SetLine4(Inverse, -59,  -98,  31,  -36,  53)
        SetLine5(Inverse, 260,  435,  -136,  160,  -236)
        
      Case 6
        SetLine1(Inverse, 752,  502,  1002,  257,  408)
        SetLine2(Inverse, 1200,  801,  1599,  410,  651)
        SetLine3(Inverse, 319,  213,  425,  109,  173)
        SetLine4(Inverse, 9,  6,  12,  3,  5)
        SetLine5(Inverse, -86,  -57,  -114,  -29,  -47)
        
      Case 7
        SetLine1(Inverse, -1371, -4927, -4971, 1170, -3647)
        SetLine2(Inverse, 497, 1786, 1802, -424, 1322)
        SetLine3(Inverse, 1284, 4615, 4656, -1096, 3416)
        SetLine4(Inverse, 62, 223, 225, -53, 165)
        SetLine5(Inverse, 1, 4, 4, -1, 3)
        
      Case 8
        SetLine1(Inverse, -1, -12, 9, 10, 14)
        SetLine2(Inverse, -7, -118, 88, 94, 137)
        SetLine3(Inverse, 0, 9, -7, -7, -11)
        SetLine4(Inverse, 0, 3, -2, -2, -3)
        SetLine5(Inverse, 2, 28, -21, -23, -33)
        
      Case 9
        SetLine1(Inverse, -5843, -6073, -1138, -1058, -526)
        SetLine2(Inverse, -14176, -14734, -2761, -2567, -1276)
        SetLine3(Inverse, 11332, 11778, 2207, 2052, 1020)
        SetLine4(Inverse, -3733, -3880, -727, -676, -336)
        SetLine5(Inverse, -77, -80, -15, -14, -7)
        
      Case 10
        SetLine1(Inverse, 537, 251, 70, 282, -14)
        SetLine2(Inverse, -1143, -534, -149, -600, 30)
        SetLine3(Inverse, 1297, 606, 169, 681, -34)
        SetLine4(Inverse, 1748, 817, 228, 918, -46)
        SetLine5(Inverse, 798, 373, 104, 419, -21)
        
      Case 11
        SetLine1(Inverse, 425, -271, 203, 484, -17)
        SetLine2(Inverse, 111, -70, 53, 126, -4)
        SetLine3(Inverse, -172, 110, -82, -196, 7)
        SetLine4(Inverse, 333, -212, 159, 379, -13)
        SetLine5(Inverse, -48, 31, -23, -55, 2)
        
      Case 12
        SetLine1(Inverse, -6203, -5423, 7050, -5310, -2740)
        SetLine2(Inverse, 1868, 1633, -2123, 1599, 825)
        SetLine3(Inverse, 1098, 960, -1248, 940, 485)
        SetLine4(Inverse, -6210, -5429, 7058, -5316, -2743)
        SetLine5(Inverse, -5551, -4853, 6309, -4752, -2452)
        
      Case 13
        SetLine1(Inverse, -3754, -4536, -889, -1049, 264)
        SetLine2(Inverse, 1449, 1751, 343, 405, -102)
        SetLine3(Inverse, -1238, -1496, -293, -346, 87)
        SetLine4(Inverse, -1195, -1444, -283, -334, 84)
        SetLine5(Inverse, 2276, 2750, 539, 636, -160)
        
      Case 14
        SetLine1(Inverse, -3122, -1014, -859, 8621, 7066)
        SetLine2(Inverse, -3347, -1087, -921, 9242, 7575)
        SetLine3(Inverse, 1530, 497, 421, -4225, -3463)
        SetLine4(Inverse, 745, 242, 205, -2057, -1686)
        SetLine5(Inverse, 1512, 491, 416, -4175, -3422)
        
      Case 15
        SetLine1(Inverse, -871, -1489, -1450, 67, -63)
        SetLine2(Inverse, -1519, -2597, -2529, 117, -110)
        SetLine3(Inverse, 402, 687, 669, -31, 29)
        SetLine4(Inverse, -1768, -3023, -2944, 136, -128)
        SetLine5(Inverse, 1520, 2599, 2531, -117, 110)
        
      Case 16
        SetLine1(Inverse, 4994, 5031, 4542, -3063, -5801)
        SetLine2(Inverse, 3657, 3684, 3326, -2243, -4248)
        SetLine3(Inverse, 4177, 4208, 3799, -2562, -4852)
        SetLine4(Inverse, -1492, -1503, -1357, 915, 1733)
        SetLine5(Inverse, 551, 555, 501, -338, -640)
        
      Case 17
        SetLine1(Inverse, -340, -91, -358, 31, 364)
        SetLine2(Inverse, 396, 106, 417, -36, -424)
        SetLine3(Inverse, 247, 66, 260, -22, -264)
        SetLine4(Inverse, -150, -40, -158, 13, 160)
        SetLine5(Inverse, -243, -65, -256, 21, 259)
        
      Case 18
        SetLine1(Inverse, 132, 141, -311, 29, -194)
        SetLine2(Inverse, -503, -538, 1187, -110, 739)
        SetLine3(Inverse, -548, -586, 1293, -120, 805)
        SetLine4(Inverse, -55, -59, 130, -12, 81)
        SetLine5(Inverse, -978, -1046, 2308, -214, 1437)
        
      Case 19
        SetLine1(Inverse, 1969, 1451, 1157, 879, -212)
        SetLine2(Inverse, -2182, -1608, -1282, -974, 235)
        SetLine3(Inverse, -650, -479, -382, -290, 70)
        SetLine4(Inverse, 148, 109, 87, 66, -16)
        SetLine5(Inverse, -1559, -1149, -916, -696, 168)
        
      Case 20
        SetLine1(Inverse, 736, 1001, 416, -512, 36)
        SetLine2(Inverse, -161, -219, -91, 112, -8)
        SetLine3(Inverse, 357, 485, 201, -248, 17)
        SetLine4(Inverse, 479, 651, 270, -333, 23)
        SetLine5(Inverse, 167, 227, 94, -116, 8)
        
      Case 21
        SetLine1(Inverse, -541, 1529, -1260, 1287, -249)
        SetLine2(Inverse, 302, -853, 703, -718, 139)
        SetLine3(Inverse, 100, -283, 233, -238, 46)
        SetLine4(Inverse, 178, -504, 415, -424, 82)
        SetLine5(Inverse, 237, -670, 552, -564, 109)
        
      Case 22
        SetLine1(Inverse, -2192, 1259, 1559, -117, 2471)
        SetLine2(Inverse, -190, 109, 135, -10, 214)
        SetLine3(Inverse, 353, -203, -251, 19, -398)
        SetLine4(Inverse, 284, -163, -202, 15, -320)
        SetLine5(Inverse, -1219, 700, 867, -65, 1374)
        
      Case 23
        SetLine1(Inverse, 1732, 791, 417, 1277, -24)
        SetLine2(Inverse, -3120, -1425, -751, -2300, 43)
        SetLine3(Inverse, 1811, 827, 436, 1335, -25)
        SetLine4(Inverse, -727, -332, -175, -536, 10)
        SetLine5(Inverse, 155, 71, 37, 114, -2)
        
      Case 24
        SetLine1(Inverse, 112, -374, 1547, 1224, 137)
        SetLine2(Inverse, 235, -784, 3243, 2566, 287)
        SetLine3(Inverse, -268, 894, -3697, -2925, -327)
        SetLine4(Inverse, 136, -454, 1877, 1485, 166)
        SetLine5(Inverse, 77, -257, 1063, 841, 94)
        
      Case 25
        SetLine1(Inverse, -2572, -836, 1249, 874, -322)
        SetLine2(Inverse, 10193, 3313, -4950, -3464, 1276)
        SetLine3(Inverse, 2963, 963, -1439, -1007, 371)
        SetLine4(Inverse, 4458, 1449, -2165, -1515, 558)
        SetLine5(Inverse, -1948, -633, 946, 662, -244)
        
      Case 26
        SetLine1(Inverse, -376, 5482, 3002, 2869, -1171)
        SetLine2(Inverse, -438, 6386, 3497, 3342, -1364)
        SetLine3(Inverse, -201, 2931, 1605, 1534, -626)
        SetLine4(Inverse, 348, -5075, -2779, -2656, 1084)
        SetLine5(Inverse, 150, -2186, -1197, -1144, 467)
        
      Case 27
        SetLine1(Inverse, -7499, 2098, -3129, 2766, 4434)
        SetLine2(Inverse, -3885, 1087, -1621, 1433, 2297)
        SetLine3(Inverse, 2706, -757, 1129, -998, -1600)
        SetLine4(Inverse, -1201, 336, -501, 443, 710)
        SetLine5(Inverse, -247, 69, -103, 91, 146)
        
      Case 28
        SetLine1(Inverse, -4405, 2765, -92, -2939, -253)
        SetLine2(Inverse, 7905, -4962, 165, 5274, 454)
        SetLine3(Inverse, 4456, -2797, 93, 2973, 256)
        SetLine4(Inverse, 1340, -841, 28, 894, 77)
        SetLine5(Inverse, 1394, -875, 29, 930, 80)
        
      Case 29
        SetLine1(Inverse, -264, 1042, -647, -2267, 2370)
        SetLine2(Inverse, -18, 71, -44, -155, 162)
        SetLine3(Inverse, 220, -868, 539, 1889, -1975)
        SetLine4(Inverse, 149, -588, 365, 1279, -1337)
        SetLine5(Inverse, -133, 525, -326, -1142, 1194)
        
      Case 30
        SetLine1(Inverse, -333, -136, 270, 371, 464)
        SetLine2(Inverse, 2082, 850, -1688, -2319, -2901)
        SetLine3(Inverse, 1056, 431, -856, -1176, -1471)
        SetLine4(Inverse, -1009, -412, 818, 1124, 1406)
        SetLine5(Inverse, 2214, 904, -1795, -2466, -3085)
        
      Case 31
        SetLine1(Inverse, 518, -35, 33, 170, -9)
        SetLine2(Inverse, -15517, 1051, -986, -5093, 268)
        SetLine3(Inverse, -10764, 729, -684, -3533, 186)
        SetLine4(Inverse, 1447, -98, 92, 475, -25)
        SetLine5(Inverse, 5728, -388, 364, 1880, -99)
        
      Case 32
        SetLine1(Inverse, -664, -221, 611, 618, 623)
        SetLine2(Inverse, 274, 91, -252, -255, -257)
        SetLine3(Inverse, 388, 129, -357, -361, -364)
        SetLine4(Inverse, 119, 40, -110, -111, -112)
        SetLine5(Inverse, -167, -55, 153, 155, 156)
        
      Case 33
        SetLine1(Inverse, 2115, 689, -970, -1441, 389)
        SetLine2(Inverse, 1136, 370, -521, -774, 209)
        SetLine3(Inverse, -1544, -503, 708, 1052, -284)
        SetLine4(Inverse, 495, 161, -227, -337, 91)
        SetLine5(Inverse, 619, 202, -284, -422, 114)
        
      Case 34
        SetLine1(Inverse, 6125, -1027, 4276, 3102, -93)
        SetLine2(Inverse, -1706, 286, -1191, -864, 26)
        SetLine3(Inverse, 7503, -1258, 5238, 3800, -114)
        SetLine4(Inverse, -4873, 817, -3402, -2468, 74)
        SetLine5(Inverse, -918, 154, -641, -465, 14)
        
      Case 35
        SetLine1(Inverse, -2359, 2068, -4303, -1371, 1531)
        SetLine2(Inverse, 795, -697, 1450, 462, -516)
        SetLine3(Inverse, 470, -412, 857, 273, -305)
        SetLine4(Inverse, -721, 632, -1315, -419, 468)
        SetLine5(Inverse, -382, 335, -697, -222, 248)
        
      Case 36
        SetLine1(Inverse, 39, 160, -269, -15, 166)
        SetLine2(Inverse, -272, -1121, 1886, 105, -1165)
        SetLine3(Inverse, 487, 2007, -3377, -188, 2086)
        SetLine4(Inverse, -549, -2262, 3806, 212, -2351)
        SetLine5(Inverse, -321, -1323, 2226, 124, -1375)
        
      Case 37
        SetLine1(Inverse, -49,  30,  -7,  8,  -7)
        SetLine2(Inverse, 2640,  -1618,  374,  -431,  381)
        SetLine3(Inverse, 62,  -38,  9,  -10,  9)
        SetLine4(Inverse, 741,  -454,  105,  -121,  107)
        SetLine5(Inverse, 305,  -187,  43,  -50,  44)
        
      Case 38
        SetLine1(Inverse, 36,  -122,  297,  199,  -179)
        SetLine2(Inverse, 249,  -841,  2044,  1370,  -1231)
        SetLine3(Inverse, 27,  -92,  224,  150,  -135)
        SetLine4(Inverse, 36,  -121,  294,  197,  -177)
        SetLine5(Inverse, 43,  -145,  352,  236,  -212)
        
      Case 39
        SetLine1(Inverse, -754,  1782,  -667,  929,  1452)
        SetLine2(Inverse, 2150,  -5081,  1902,  -2649,  -4140)
        SetLine3(Inverse, -340,  804,  -301,  419,  655)
        SetLine4(Inverse, 1172,  -2770,  1037,  -1444,  -2257)
        SetLine5(Inverse, -633,  1496,  -560,  780,  1219)
        
      Case 40
        SetLine1(Inverse, -61,  -24,  154,  28,  -35)
        SetLine2(Inverse, -612,  -242,  1545,  281,  -351)
        SetLine3(Inverse, 157,  62,  -396,  -72,  90)
        SetLine4(Inverse, -492,  -195,  1243,  226,  -282)
        SetLine5(Inverse, -94,  -37,  237,  43,  -54)
        
      Case 41
        SetLine1(Inverse, -156,  -398,  43,  -338,  -95)
        SetLine2(Inverse, 215,  549,  -59,  466,  131)
        SetLine3(Inverse, 950,  2425,  -261,  2059,  579)
        SetLine4(Inverse, 15,  38,  -4,  32,  9)
        SetLine5(Inverse, -18,  -46,  5,  -39,  -11)
        
      Case 42
        SetLine1(Inverse, 310,  -939,  -445,  4,  -345)
        SetLine2(Inverse, 71,  -215,  -102,  1,  -79)
        SetLine3(Inverse, -716,  2169,  1028,  -9,  797)
        SetLine4(Inverse, 1119,  -3389,  -1606,  14,  -1245)
        SetLine5(Inverse, 158,  -479,  -227,  2,  -176)
        
      Case 43
        SetLine1(Inverse, 225,  -283,  182,  -155,  -258)
        SetLine2(Inverse, -340,  428,  -275,  234,  390)
        SetLine3(Inverse, 251,  -316,  203,  -173,  -288)
        SetLine4(Inverse, 189,  -238,  153,  -130,  -217)
        SetLine5(Inverse, 234,  -294,  189,  -161,  -268)
        
      Case 44
        SetLine1(Inverse, -379,  417,  383,  -158,  -70)
        SetLine2(Inverse, -1651,  1817,  1669,  -689,  -306)
        SetLine3(Inverse, -1215,  1337,  1228,  -507,  -225)
        SetLine4(Inverse, 556,  -612,  -562,  232,  103)
        SetLine5(Inverse, -448,  493,  453,  -187,  -83)
        
      Case 45
        SetLine1(Inverse, -36,  126,  -83,  62,  -58)
        SetLine2(Inverse, -428,  1497,  -988,  737,  -690)
        SetLine3(Inverse, 237,  -829,  547,  -408,  382)
        SetLine4(Inverse, -932,  3261,  -2152,  1605,  -1503)
        SetLine5(Inverse, 274,  -959,  633,  -472,  442)
        
      Case 46
        SetLine1(Inverse, -563,  6890,  -424,  -5442,  -371)
        SetLine2(Inverse, 138,  -1689,  104,  1334,  91)
        SetLine3(Inverse, 340,  -4159,  256,  3285,  224)
        SetLine4(Inverse, 126,  -1542,  95,  1218,  83)
        SetLine5(Inverse, -158,  1932,  -119,  -1526,  -104)
        
      Case 47
        SetLine1(Inverse, -88,  1169,  932,  -2845,  1231)
        SetLine2(Inverse, -185,  2456,  1958,  -5977,  2586)
        SetLine3(Inverse, 101,  -1342,  -1070,  3266,  -1413)
        SetLine4(Inverse, 27,  -360,  -287,  876,  -379)
        SetLine5(Inverse, 91,  -1208,  -963,  2940,  -1272)
        
      Case 48
        SetLine1(Inverse, -1311,  -1431,  -56,  -3473,  -710)
        SetLine2(Inverse, 258,  282,  11,  684,  140)
        SetLine3(Inverse, 493,  538,  21,  1306,  267)
        SetLine4(Inverse, 491,  536,  21,  1301,  266)
        SetLine5(Inverse, -373,  -407,  -16,  -988,  -202)
        
      Case 49
        SetLine1(Inverse, 1850,  -1894,  4001,  277,  25)
        SetLine2(Inverse, 374,  -383,  809,  56,  5)
        SetLine3(Inverse, 1,  -1,  2,  0,  0)
        SetLine4(Inverse, -294,  301,  -636,  -44,  -4)
        SetLine5(Inverse, 676,  -692,  1462,  101,  9)
        
    EndSelect
    
    MaxChar.l = ReadLong(FileID) - 1
    
    For Index = 0 To MaxChar Step 5
      
      ReadData(FileID, @VectorCoded, SizeOf(Vector5Q))
      Product(VectorDecoded, Inverse, VectorCoded)
      String.s = String + Chr(VectorDecoded\i) + Chr(VectorDecoded\j) + Chr(VectorDecoded\k) + Chr(VectorDecoded\l) + Chr(VectorDecoded\m)
      
    Next
    
    ProcedureReturn String
  EndProcedure
  
  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  ; <<<<< Read All other types <<<<<
  
  Procedure.b ME_ReadByte(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.a ME_ReadAsciiCharacter(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.w ME_ReadWord(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.c ME_ReadCharacter(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.u ME_ReadUnicodeCharacter(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.i ME_ReadInteger(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.l ME_ReadLong(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.q ME_ReadQuad(FileID.l)
    
    ProcedureReturn Val(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.f ME_ReadFloat(FileID.l)
    
    ProcedureReturn ValF(ME_ReadString(FileID))
  EndProcedure
  
  Procedure.d ME_ReadDouble(FileID.l)
    
    ProcedureReturn ValD(ME_ReadString(FileID))
  EndProcedure
  
  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  ; <<<<< WriteEncodedString <<<<<
  
  Procedure ME_WriteString(FileID.l, String.s)
    
    Protected Matrix.Matrix55Q, VectorCoded.Vector5Q, VectorDecoded.Vector5Q
    
    MatrixID = Random(49)
    
    Select MatrixID
        
      Case 0
        SetLine1(Matrix, -8, -5, -3, 8, 0)
        SetLine2(Matrix, -4, -2, -2, 5, 0)
        SetLine3(Matrix, 2, 2, 2, -6, 1)
        SetLine4(Matrix, -6, -2, -3, 5, -8)
        SetLine5(Matrix, 1, 1, 2, -7, -5)
        
      Case 1
        SetLine1(Matrix, 4, -6, -6, 3, -3)
        SetLine2(Matrix, 6, -2, 9, -6, 3)
        SetLine3(Matrix, -8, 7, 6, -4, 3)
        SetLine4(Matrix, -7, 1, 6, -7, 2)
        SetLine5(Matrix, 6, -4, 8, -7, 6)
        
      Case 2
        SetLine1(Matrix, 4, 0, 8, 9, 5)
        SetLine2(Matrix, -8, 4, 2, 0, -1)
        SetLine3(Matrix, -8, -8, -1, -6, 1)
        SetLine4(Matrix, -6, -7, 5, 8, -2)
        SetLine5(Matrix, 3, 1, 4, 2, 5)
        
      Case 3
        SetLine1(Matrix, -2, 6, 7, -3, 8)
        SetLine2(Matrix, 3, -7, -9, 2, -9)
        SetLine3(Matrix, 5, -5, -9, -6, -8)
        SetLine4(Matrix, -1, -9, -2, 6, 2)
        SetLine5(Matrix, -2, -9, 0, 8, -4)
        
      Case 4
        SetLine1(Matrix, 2,  2,  4,  -4,  -1)
        SetLine2(Matrix, -2,  0,  -5,  1,  4)
        SetLine3(Matrix, -2,  1,  3,  -2,  3)
        SetLine4(Matrix, 2,  7,  5,  -3,  5)
        SetLine5(Matrix, -5,  -6,  6,  -2,  -3)
        
      Case 5
        SetLine1(Matrix, -2,  5,  2,  0,  2)
        SetLine2(Matrix, 0,  -4,  -4,  4,  7)
        SetLine3(Matrix, -4,  5,  1,  4,  7)
        SetLine4(Matrix, -9,  7,  7,  -6,  -6)
        SetLine5(Matrix, -6,  0,  -1,  1,  7)
        
      Case 6
        SetLine1(Matrix, -3,  1,  3,  -8,  -2)
        SetLine2(Matrix, 1,  -3,  9,  7,  1)
        SetLine3(Matrix, -3,  3,  -4,  2,  1)
        SetLine4(Matrix, 9,  -4,  -6,  -6,  0)
        SetLine5(Matrix, 6,  -3,  -3,  5,  0)
        
      Case 7
        SetLine1(Matrix, -2, -5, 0, -4, -8)
        SetLine2(Matrix, 8, 4, 7, 0, -8)
        SetLine3(Matrix, -4, 1, -5, 7, 5)
        SetLine4(Matrix, 5, 9, 2, -3, 0)
        SetLine5(Matrix, -3, -2, -2, -9, 7)
        
      Case 8
        SetLine1(Matrix, 4, -1, -3, -5, -1)
        SetLine2(Matrix, 2, 0, -1, 2, 1)
        SetLine3(Matrix, 7, 1, -1, 5, 7)
        SetLine4(Matrix, 5, -1, -2, -4, -1)
        SetLine5(Matrix, -6, 0, 1, 1, -3)
        
      Case 9
        SetLine1(Matrix, 2, 4, 9, 9, 0)
        SetLine2(Matrix, -3, -2, -7, -9, 2)
        SetLine3(Matrix, 2, -8, -7, 6, 0)
        SetLine4(Matrix, 8, -3, -1, -4, -8)
        SetLine5(Matrix, -8, 2, -2, -1, -7)
        
      Case 10
        SetLine1(Matrix, -1, -2, 0, -1, 0)
        SetLine2(Matrix, 4, 0, -4, -1, 6)
        SetLine3(Matrix, 3, -5, -6, 3, -6)
        SetLine4(Matrix, -2, 5, 5, 2, -4)
        SetLine5(Matrix, 8, -1, -1, -1, -3)
        
      Case 11
        SetLine1(Matrix, -1, -3, 0, 3, 5)
        SetLine2(Matrix, 3, 7, -3, -8, -2)
        SetLine3(Matrix, 1, -6, 8, 5, 1)
        SetLine4(Matrix, 2, 9, -5, -9, -6)
        SetLine5(Matrix, -4, -2, 1, 6, -2)
        
      Case 12
        SetLine1(Matrix, -1, 6, -9, 3, -2)
        SetLine2(Matrix, -6, 4, 9, 7, 2)
        SetLine3(Matrix, -1, 6, -6, 8, -7)
        SetLine4(Matrix, 7, 1, -2, 1, -9)
        SetLine5(Matrix, -2, -8, -9, -2, 0)
        
      Case 13
        SetLine1(Matrix, 4, 2, 0, 7, 9)
        SetLine2(Matrix, -5, -3, -2, -3, -9)
        SetLine3(Matrix, -2, -2, 4, -6, -3)
        SetLine4(Matrix, 9, 6, 4, -8, 9)
        SetLine5(Matrix, 0, -6, -5, -4, -1)
        
      Case 14
        SetLine1(Matrix, -1, 2, -6, 9, 4)
        SetLine2(Matrix, -3, 3, 1, 9, -5)
        SetLine3(Matrix, 8, -9, 5, -5, -6)
        SetLine4(Matrix, 5, 1, 5, 3, 6)
        SetLine5(Matrix, -6, -1, -8, 1, -7)
        
      Case 15
        SetLine1(Matrix, -2, -1, 2, -2, -5)
        SetLine2(Matrix, -8, 0, -8, 9, 8)
        SetLine3(Matrix, 9, 1, 7, -8, -5)
        SetLine4(Matrix, -9, 3, -5, -1, -2)
        SetLine5(Matrix, 0, -6, -5, -2, -7)
        
      Case 16
        SetLine1(Matrix, 1, -2, -3, -7, 8)
        SetLine2(Matrix, 8, -8, -1, 4, -1)
        SetLine3(Matrix, -9, 4, 6, -5, -4)
        SetLine4(Matrix, 9, -1, -9, 1, -4)
        SetLine5(Matrix, -4, -5, 6, -7, 5)
        
      Case 17
        SetLine1(Matrix, -6, -8, 7, 4, 0)
        SetLine2(Matrix, 5, 4, 2, 9, -4)
        SetLine3(Matrix, -2, 1, -8, -6, 0)
        SetLine4(Matrix, 8, 6, 2, 1, 0)
        SetLine5(Matrix, -7, -6, -1, 0, -1)
        
      Case 18
        SetLine1(Matrix, 2, -9, 1, 6, 4)
        SetLine2(Matrix, 0, -5, -7, -9, 7)
        SetLine3(Matrix, 2, -4, -1, -2, 3)
        SetLine4(Matrix, -1, 9, -8, -5, 0)
        SetLine5(Matrix, -2, -2, -4, 0, 3)
        
      Case 19
        SetLine1(Matrix, -2, -6, 3, 4, 5)
        SetLine2(Matrix, -2, 2, -5, -8, -4)
        SetLine3(Matrix, 4, 6, -3, 1, -2)
        SetLine4(Matrix, 3, 2, 5, 1, -1)
        SetLine5(Matrix, 2, -1, -2, -8, 4)
        
      Case 20
        SetLine1(Matrix, -1, -6, 8, -4, -7)
        SetLine2(Matrix, 1, 4, -4, 0, 8)
        SetLine3(Matrix, 2, 3, 4, -4, -3)
        SetLine4(Matrix, 2, 1, 7, -9, 3)
        SetLine5(Matrix, -2, -9, 1, 0, -2)
        
      Case 21
        SetLine1(Matrix, 4, 5, 3, -2, 3)
        SetLine2(Matrix, -2, -2, -3, -1, 0)
        SetLine3(Matrix, -8, -8, 4, -5, -6)
        SetLine4(Matrix, -3, -2, 7, -3, -5)
        SetLine5(Matrix, 4, 7, -9, 8, -2)
        
      Case 22
        SetLine1(Matrix, 4, -5, 2, -5, -7)
        SetLine2(Matrix, 0, -2, -5, -8, -3)
        SetLine3(Matrix, -2, -7, -1, -6, 3)
        SetLine4(Matrix, 4, 0, 1, -9, -9)
        SetLine5(Matrix, 5, 1, 5, 3, -7)
        
      Case 23
        SetLine1(Matrix, 1, 5, 7, -1, 3)
        SetLine2(Matrix, -2, -8, -8, 9, -3)
        SetLine3(Matrix, -7, -9, -5, 8, -7)
        SetLine4(Matrix, 2, 1, -3, -7, 0)
        SetLine5(Matrix, -9, -6, -5, -9, -4)
        
      Case 24
        SetLine1(Matrix, 1, -3, -8, -8, -6)
        SetLine2(Matrix, 1, -1, -2, -7, 7)
        SetLine3(Matrix, 5, -6, -5, -7, 6)
        SetLine4(Matrix, -7, 8, 7, 8, -4)
        SetLine5(Matrix, 8, -4, -5, -5, -8)
        
      Case 25
        SetLine1(Matrix, 2, 1, -8, 2, -5)
        SetLine2(Matrix, -8, 0, 8, -6, 9)
        SetLine3(Matrix, 3, 6, -6, -8, 0)
        SetLine4(Matrix, -9, -6, -4, 9, -5)
        SetLine5(Matrix, -8, -1, 9, -7, 3)
        
      Case 26
        SetLine1(Matrix, 2, -2, -9, -9, 8)
        SetLine2(Matrix, -6, 3, -2, -3, -2)
        SetLine3(Matrix, 6, 1, -2, 4, 6)
        SetLine4(Matrix, 3, -5, 8, 2, -1)
        SetLine5(Matrix, -6, 5, 8, 4, 1)
        
      Case 27
        SetLine1(Matrix, 1, -2, -1, -1, -5)
        SetLine2(Matrix, -6, 8, -8, -5, -7)
        SetLine3(Matrix, -2, -4, -9, 7, -9)
        SetLine4(Matrix, 5, -8, 6, 9, -4)
        SetLine5(Matrix, 0, -5, -8, 0, -9)
        
      Case 28
        SetLine1(Matrix, 3, 2, -3, 7, 1)
        SetLine2(Matrix, -3, -3, -1, 7, 4)
        SetLine3(Matrix, -3, 3, -7, 3, -7)
        SetLine4(Matrix, -8, -6, 3, -4, 3)
        SetLine5(Matrix, 9, 1, 9, 0, -6)
        
      Case 29
        SetLine1(Matrix, 8, 8, 9, 9, 8)
        SetLine2(Matrix, -4, 4, 3, -3, 9)
        SetLine3(Matrix, -7, 7, 1, -5, 9)
        SetLine4(Matrix, -6, 1, -1, -1, 9)
        SetLine5(Matrix, -5, 2, -1, 0, 8)
        
      Case 30
        SetLine1(Matrix, 4, -4, 4, -1, 2)
        SetLine2(Matrix, -9, -9, 1, 3, 8)
        SetLine3(Matrix, 9, -5, 2, -9, 1)
        SetLine4(Matrix, 5, -2, 0, 3, 4)
        SetLine5(Matrix, -9, -1, 2, 3, 0)
        
      Case 31
        SetLine1(Matrix, 2, -1, 1, -4, 0)
        SetLine2(Matrix, 6, -1, -4, -7, -9)
        SetLine3(Matrix, 7, -3, 8, 9, 4)
        SetLine4(Matrix, -6, 3, -5, 9, -3)
        SetLine5(Matrix, 4, -8, 8, 0, -7)
        
      Case 32
        SetLine1(Matrix, -2, -6, 1, -2, -1)
        SetLine2(Matrix, -5, -7, -3, -2, 0)
        SetLine3(Matrix, -5, -3, -3, -7, 3)
        SetLine4(Matrix, 0, -8, 7, -3, 1)
        SetLine5(Matrix, 1, 2, -4, 7, -5)
        
      Case 33
        SetLine1(Matrix, -2, -4, -4, 4, 1)
        SetLine2(Matrix, 0, -8, -3, 4, 4)
        SetLine3(Matrix, -5, -2, -8, 1, 0)
        SetLine4(Matrix, -2, -7, -3, 9, 5)
        SetLine5(Matrix, -9, 5, -4, 7, 6)
        
      Case 34
        SetLine1(Matrix, 2, -2, 1, 4, 4)
        SetLine2(Matrix, -4, -4, -3, -9, 4)
        SetLine3(Matrix, 2, -3, -8, -8, -4)
        SetLine4(Matrix, -8, 7, 8, 0, -1)
        SetLine5(Matrix, 1, 8, -2, -5, 2)
        
      Case 35
        SetLine1(Matrix, -1, -4, 5, 0, 4)
        SetLine2(Matrix, -1, -9, 1, -6, 0)
        SetLine3(Matrix, -1, -5, 1, 0, -3)
        SetLine4(Matrix, 0, 9, -8, 1, 7)
        SetLine5(Matrix, -3, 0, 2, 9, 4)
        
      Case 36
        SetLine1(Matrix, 1, -1, -1, -5, 8)
        SetLine2(Matrix, 0, -8, -4, 1, -1)
        SetLine3(Matrix, -3, -9, -6, -4, 5)
        SetLine4(Matrix, 1, -4, 7, 3, 9)
        SetLine5(Matrix, -5, -7, -5, -6, 8)
        
      Case 37 
        SetLine1(Matrix, -1,  0,  -5,  2,  -4)
        SetLine2(Matrix, -2,  -1,  -4,  5,  -3)
        SetLine3(Matrix, -5,  -1,  7,  1,  4)
        SetLine4(Matrix, 5,  2,  -6,  -3,  -8)
        SetLine5(Matrix, 9,  -1,  4,  3,  2)
        
      Case 38
        SetLine1(Matrix, 4,  -1,  -3,  4,  1)
        SetLine2(Matrix, 4,  1,  -5,  0,  -6)
        SetLine3(Matrix, -5,  1,  3,  3,  -6)
        SetLine4(Matrix, 2,  2,  -7,  -7,  -3)
        SetLine5(Matrix, -8,  3,  0,  -2,  -9)
        
      Case 39
        SetLine1(Matrix, -1,  2,  5,  2,  9)
        SetLine2(Matrix, 2,  -3,  5,  5,  -6)
        SetLine3(Matrix, 9,  0,  1,  5,  -2)
        SetLine4(Matrix, -6,  -2,  3,  5,  8)
        SetLine5(Matrix, 5,  6,  -5,  -6,  6)
        
      Case 40
        SetLine1(Matrix, 0,  2,  9,  0,  2)
        SetLine2(Matrix, 9,  -1,  -1,  0,  -1)
        SetLine3(Matrix, 3,  -1,  1,  1,  1)
        SetLine4(Matrix, 0,  4,  2,  -3,  -7)
        SetLine5(Matrix, 7,  -4,  -9,  2,  -4)
        
      Case 41
        SetLine1(Matrix, -1,  -5,  1,  4,  5)
        SetLine2(Matrix, 0,  4,  -1,  0,  -5)
        SetLine3(Matrix, 4,  -1,  1,  1,  7)
        SetLine4(Matrix, -1,  0,  0,  -2,  7)
        SetLine5(Matrix, 7,  -9,  3,  1,  -9)  
        
      Case 42
        SetLine1(Matrix, 2,  -1,  -1,  0,  -8)
        SetLine2(Matrix, -1,  1,  -3,  -1,  -5)
        SetLine3(Matrix, 9,  -9,  1,  -1,  -2)
        SetLine4(Matrix, 8,  1,  2,  -1,  0)
        SetLine5(Matrix, -7,  8,  6,  4,  9) 
        
      Case 43
        SetLine1(Matrix, -2,  0,  -1,  0,  3)
        SetLine2(Matrix, 1,  5,  1,  4,  2)
        SetLine3(Matrix, 8,  -3,  -6,  -2,  -4)
        SetLine4(Matrix, -2,  -1,  -2,  2,  1)
        SetLine5(Matrix, 4,  -7,  -5,  -7,  -3)
        
      Case 44
        SetLine1(Matrix, -2,  -3,  -2,  -9,  7)
        SetLine2(Matrix, -1,  -2,  -1,  -8,  1)
        SetLine3(Matrix, 2,  1,  -3,  1,  4)
        SetLine4(Matrix, 7,  7,  -6,  6,  -8)
        SetLine5(Matrix, 0,  -6,  2,  -7,  8)
        
      Case 45
        SetLine1(Matrix, 8,  0,  7,  0,  -5)
        SetLine2(Matrix, 3,  -2,  -2,  0,  -1)
        SetLine3(Matrix, 5,  0,  4,  2,  4)
        SetLine4(Matrix, 9,  5,  6,  -2,  -3)
        SetLine5(Matrix, 4,  1,  -8,  -5,  -8)
        
      Case 46
        SetLine1(Matrix, 1,  -2,  2,  -5,  -5)
        SetLine2(Matrix, 2,  -5,  6,  7,  7)
        SetLine3(Matrix, 2,  6,  -2,  4,  -3)
        SetLine4(Matrix, 2,  -7,  7,  9,  9)
        SetLine5(Matrix, 4,  6,  8,  1,  9)
        
      Case 47
        SetLine1(Matrix, 2,  -4,  -1,  -7,  -3)
        SetLine2(Matrix, -5,  7,  7,  -8,  4)
        SetLine3(Matrix, 2,  0,  -5,  5,  6)
        SetLine4(Matrix, 2,  3,  3,  -1,  5)
        SetLine5(Matrix, 8,  0,  4,  1,  3)
        
      Case 48
        SetLine1(Matrix, -1,  1,  2,  -9,  -5)
        SetLine2(Matrix, -3,  1,  -4,  -3,  2)
        SetLine3(Matrix, 0,  -1,  -8,  4,  -6)
        SetLine4(Matrix, 1,  -2,  0,  6,  3)
        SetLine5(Matrix, 3,  6,  5,  -7,  -9)
        
      Case 49
        SetLine1(Matrix, 2,  -8,  -1,  7,  2)
        SetLine2(Matrix, 0,  -8,  -6,  -1,  4)
        SetLine3(Matrix, -1,  0,  -2,  -4,  1)
        SetLine4(Matrix, 1,  -1,  -6,  5,  0)
        SetLine5(Matrix, 1,  -3,  6,  -9,  -5)
        
    EndSelect
    
    WriteByte(FileID, MatrixID)
    MaxChar.l = Len(String) - 1
    WriteLong(FileID, MaxChar + 1)
    
    For Index = 0 To MaxChar Step 5
      
      VectorDecoded\i = Asc(Mid(String, Index + 1, 1))
      VectorDecoded\j = Asc(Mid(String, Index + 2, 1))
      VectorDecoded\k = Asc(Mid(String, Index + 3, 1))
      VectorDecoded\l = Asc(Mid(String, Index + 4, 1))
      VectorDecoded\m = Asc(Mid(String, Index + 5, 1))
      
      Product(VectorCoded, Matrix, VectorDecoded)
      WriteData(FileID, @VectorCoded, SizeOf(Vector5Q))
      
    Next
    
  EndProcedure
  
  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  ; <<<<< ME_Write All other types <<<<<
  
  Procedure ME_WriteAsciiCharacter(FileID.l, Number.a)
    
    ME_WriteString(FileID, RSet(Str(Number), 6, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteUnicodeCharacter(FileID.l, Number.u)
    
    ME_WriteString(FileID, RSet(Str(Number), 10, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteCharacter(FileID.l, Number.c)
    
    ME_WriteString(FileID, RSet(Str(Number), 10, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteByte(FileID.l, Number.b)
    
    If Number < 0
      Sign.s = "-"
      Number = Number * -1
    EndIf
    
    ME_WriteString(FileID, Sign + RSet(Str(Number), 6, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteWord(FileID.l, Number.w)
    
    If Number < 0
      Sign.s = "-"
      Number = Number * -1
    EndIf
    
    ME_WriteString(FileID, Sign + RSet(Str(Number), 10, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteLong(FileID.l, Number.l)
    
    If Number < 0
      Sign.s = "-"
      Number = Number * -1
    EndIf
    
    ME_WriteString(FileID, Sign + RSet(Str(Number), 22, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteInteger(FileID.l, Number.i)
    
    If Number < 0
      Sign.s = "-"
      Number = Number * -1
    EndIf
    
    ME_WriteString(FileID, Sign + RSet(Str(Number), 42, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteQuad(FileID.l, Number.q)
    
    If Number < 0
      Sign.s = "-"
      Number = Number * -1
    EndIf
    
    ME_WriteString(FileID, Sign + RSet(Str(Number), 42, "0"))
    
  EndProcedure 
  
  Procedure ME_WriteFloat(FileID.l, Number.f)
    
    ME_WriteString(FileID, StrF(Number, 14))
    
  EndProcedure 
  
  Procedure ME_WriteDouble(FileID.l, Number.d)
    
    ME_WriteString(FileID, StrD(Number, 25))
    
  EndProcedure 
  
EndModule

CompilerIf #PB_Compiler_IsMainFile
  
  Macro AddElementEx(ListName, Element)
    AddElement(ListName)
    ListName = Element
  EndMacro
  
  NewList Text.s()
  
  AddElementEx(Text(), FormatDate("%dd-%mm-%yyyy - %hh:%ii:%ss", Date()))
  AddElementEx(Text(), "FreeMat 4.0 (Similar to MatLab but without Simulink)")
  AddElementEx(Text(), "PureBasic is the best programming language, period !")
  AddElementEx(Text(), "Ubuntu Gnome 15.10 x64")
  AddElementEx(Text(), CPUName())
  AddElementEx(Text(), ComputerName())
  AddElementEx(Text(), UserName())
  
  If CreateFile(0, "Test Encoded.dat")
    
    MatrixEncoded::ME_WriteLong(0, ListSize(Text()))
    
    ForEach Text()
      MatrixEncoded::ME_WriteString(0, Text())
    Next 
    
    MatrixEncoded::ME_WriteFloat(0, -10*#PI)
    MatrixEncoded::ME_WriteDouble(0, -100*#PI)
    
    CloseFile(0)
    
  EndIf 
  
  If ReadFile(1, "Test Encoded.dat")
    
    Max = MatrixEncoded::ME_ReadLong(1) - 1
    
    For Index = 0 To Max
      Debug MatrixEncoded::ME_ReadString(1)
    Next 
    
    Debug MatrixEncoded::ME_ReadFloat(1)
    Debug MatrixEncoded::ME_ReadDouble(1)
    
    CloseFile(1)
    
    DeleteFile("Test Encoded.dat")
    
  EndIf 
  
CompilerEndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Read/Write Matrix Encoded - Using 5X5 matrix

Post by StarBootics »

Hello everyone,

A small update over my first code. Now my code work with 50 matrix instead of 1.

See first post.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Post Reply