* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: Why Can't I add a new record ?
« Last post by J-G on Today at 12:53:39 pm »
Well!!  Where do I start :)    -   Thanks for all the input   

I thought 'sleeping on it' might resolve the issue and to a certain extent it has ... I haven't checked yet but I suspect that the record has been written to the end of the file ---- it just happens that the file was CREATED with 20 records, only 7 of which have historic data and the rest are there but blank - so the NEXT record will be 8.   So seek(Gas_Rates,8) ought to write the 8th record  -  but it doesn't.  :(   Maybe I should rethink the rationale and only create the historic data. I was obviously only half aware last night and today will not be much better since I have a rehearsal for a performance of Belshazzar's Feast this afternoon.

I'm trying to get to grips with Dynamic arrays - but for me everything must have a 'practical reason' so the practicality is recording my energy use and Solar Power generation figures. Some of the data is known to be of fixed length - there will always be 52/3 weekly readings and 365/6 daily readings - so they can be held in static arrays but there are other 'events' which are occasional so warrant a 'Dyanamic' approach.

@ Akira1364
You surmise correctly that OpenFile(6) is effectively a wrapper. I have 8 different data files and the use of OpenFile() and CloseFile() makes my code self documenting. As I've said, I'm 'Old School' and still using reset() to open an existing file - though I am being dragged (kicking and screaming) into the present by this fantastic forum  :D

@ SkyKhan
You'll now see why there are no 'Magic' numbers.

@ Molly
Thanks -  yes your code works - well at each 'run', a console window appears and disappears and when I view the 'Test.dta',  records have been added.

@ Thaddy
Being 'Old School', I've never declared a record 'Packed' and I'm sure I could find volumes as to what benefits doing so might have. Maybe you could point me to a document? (or two) :)

So.....   I've now tried seek(fileAlias,file_pos) with write(fileAlias,Record) and that hasn't solved the issue. Am I wrong in thinking that I can in fact write a modified record back into the middle of a file?  Would using 'Packed' allow such?


2
Android / Re: Android Module Wizard
« Last post by majid.ebru on Today at 12:52:56 pm »
thank you very Mrs.jmpessoa


Hi All!

There is an updated LAMW revision!

ref https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.7.11 - 17 - Feb - 2017

   NEW! jWindowManager component

   NEW! demo AppWindowManagerDemo1
      [floating and draggable View!]

   IMPROVED!
      jForm: news methods:
         Minimize
         Restart

      jButton: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jTextView: news methods
         SetCompoundDrawables
         SetRoundCorner
         SetRadiusRoundCorner

      jRadioGroup: news methods
         SetRoundCorner
         SetRadiusRoundCorner
         
      jPanel:: news methods
         SetRoundCorner
         SetRadiusRoundCorner

      jImageView: news methods      
         SetRoundCorner
         SetRadiusRoundCorner

      jEditText: news method
         SetCompoundDrawables

      jCheckBox: news method
         SetCompoundDrawables

      jRadioButton: news method
         SetCompoundDrawables            


Thanks to All!

PS.
Hi @majid.ebru the "AppLocationDemo1" was updated!
3
General / Re: Unicode, and IntToStr and PosEx: How to make it work?
« Last post by wp on Today at 12:42:38 pm »
Juha, but he has {$modeswitch unicodestrings}. Should this make a string to a unicodestring?
4
RichMemo / Re: Detecting a Unicode language family
« Last post by rick2691 on Today at 12:42:11 pm »
@Thaddy, my statement about r5708 and my computer crash was misleading. I was intending to suggest that the problem with r5708 was on account of a system problem in my computer.

@Cyrax, I had looked for that option but did not find one. Can you tell me where the Single-Step update is located?

Rick
5
General / Re: Writring encryption algorithms with FPC as opposed to C
« Last post by Leledumbo on Today at 12:31:19 pm »
With Pascal-style arrays being reference counted, with a size variable,
Only dynamic arrays are reference counted, static arrays are not.
is the memory still laid out consecutively like a C style arrays? Or does each element have arbitrary memory addresses?
For dynamic arrays, yes, assuming you refer to the pointer to the first element instead of the whole structure.
Here's where my problem lies. I really want to use TBytes/array of byte, but even with PByte, I'm getting differing output:
I test your code and they give the same output for my test data. Perhaps you can give a suitable test data for me to test.
C:
Code: C  [Select]
  1. #include <stdint.h>
  2. #include <stdio.h>
  3.  
  4. static void tldecrypt(uint64_t key, uint8_t *data, uint64_t size)
  5. {
  6.         uint64_t tmp, t;
  7.         unsigned i;
  8.  
  9.         for (i = 0; i < ((size / 16) * 16); i += 8)
  10.         {
  11.                 *(uint64_t *)(data + i) ^= key;
  12.                 tmp = key ^ 0x4e3362bf7a4c7c26LL;
  13.                 tmp ^= tmp << 13;
  14.                 tmp ^= tmp >> 7;
  15.                 t = ((int)(data[i + 7]) << ((((i - 1) & 7) << 3)) % 32) |
  16.                         ((int)(data[i + 4]) << ((((i - 4) & 7) << 3)) % 32) |
  17.                         ((int)(data[i + 1]) << ((((i + 1) & 7) << 3)) % 32) |
  18.                         ((int)(data[i + 5]) << ((((i - 3) & 7) << 3)) % 32) |
  19.                         ((int)(data[i]) << (((i & 7) << 3)) % 32) |
  20.                         ((int)(data[i + 2]) << ((((i + 2) & 7) << 3)) % 32) |
  21.                         ((int)(data[i + 6]) << ((((i - 2) & 7) << 3)) % 32) |
  22.                         ((int)(data[i + 3]) << ((((i + 3) & 7) << 3)) % 32);
  23.                 key = tmp ^ (tmp << 17) ^ t;
  24.         }
  25.  
  26.         for (; i < size; i++)
  27.                 data[i] ^= key >> ((i & 7) << 3);
  28. }
  29.  
  30. int main() {
  31.   uint64_t key = 0x12345678;
  32.   uint8_t data[] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8};
  33.   uint64_t size = sizeof(data) / sizeof(uint8_t);
  34.   for (int i = 0; i < size; i++) printf("%02x",data[i]);puts("");
  35.   tldecrypt(key,data,size);
  36.   for (int i = 0; i < size; i++) printf("%02x",data[i]);puts("");
  37.   return 0;
  38. }
  39.  
Pascal:
Code: Pascal  [Select]
  1. procedure Decrypt(key: qword; data: pbyte; size: qword);
  2. var
  3.         tmp, t: qword;
  4.         i: dword = 0;
  5. begin
  6.         while i < ((size div 16) * 16) do
  7.         begin
  8.                 pqword(addr(data[i]))^ := pqword(addr(data[i]))^ xor key;
  9.                 tmp := key xor $4e3362bf7a4c7c26;
  10.                 tmp := tmp xor tmp shl 13;
  11.                 tmp := tmp xor tmp shr 7;
  12.                 t := (longint(data[i + 7]) shl ((((i - 1) and 7) shl 3)) mod 32) or
  13.                         (longint(data[i + 4]) shl ((((i - 4) and 7) shl 3)) mod 32) or
  14.                         (longint(data[i + 1]) shl ((((i + 1) and 7) shl 3)) mod 32) or
  15.                         (longint(data[i + 5]) shl ((((i - 3) and 7) shl 3)) mod 32) or
  16.                         (longint(data[i]) shl (((i and 7) shl 3)) mod 32) or
  17.                         (longint(data[i + 2]) shl ((((i + 2) and 7) shl 3)) mod 32) or
  18.                         (longint(data[i + 6]) shl ((((i - 2) and 7) shl 3)) mod 32) or
  19.                         (longint(data[i + 3]) shl ((((i + 3) and 7) shl 3)) mod 32);
  20.                 key := tmp xor (tmp shl 17) xor t;
  21.                 i := i + 8;
  22.         end;
  23.  
  24.         while i < size do
  25.         begin
  26.                 data[i] := data[i] xor key shr ((i and 7) shl 3);
  27.                 inc(i);
  28.         end;
  29. end;
  30.  
  31. var
  32.   key: qword = $12345678;
  33.   data: array [0..7] of byte = ($1,$2,$3,$4,$5,$6,$7,$8);
  34.   i: integer;
  35. begin
  36.   for i := low(data) to high(data) do write(hexstr(data[i],2));writeln;
  37.   Decrypt(key,@data[0],length(data));
  38.   for i := low(data) to high(data) do write(hexstr(data[i],2));writeln;
  39. end.
  40.  
6
Windows (32/64) / Re: why is lazarus not made in delphi?
« Last post by marcov on Today at 12:13:48 pm »
    *topic :wink:

    • FPC is actually older.
    • Delphi is not free.
    • Delphi is versioned. If you have 10 contributors they have 7 different versions. This is often severely underestimated. In ye old days, free versions (like Turbo Delphi 2006) were castrated
    • There is a non competition clause in some Delphi licenses iirc
    • A bit of interaction between IDE and language development can be useful
    • Many devels used Linux and FreeBSD not Windows, and actually getting an IDE on non-windows was an important objective
    [/list]
    7
    General / Re: Unicode and IntToStr: Why the warning?
    « Last post by JuhaManninen on Today at 12:08:49 pm »
    When you run it, j = 18, when in fact, it should be 15.
    No, Pos() returns a byte position and 18 is correct. UTF8Pos() would return 15.
    Often you can use byte positions also with UTF-8 data. See examples here:
     http://wiki.freepascal.org/UTF8_strings_and_characters

    Please also consider unit LazUnicode for truly portable code dealing with strings :
     http://wiki.freepascal.org/Better_Unicode_Support_in_Lazarus#CodePoint_functions_for_encoding_agnostic_code
    8
    Third party / Re: VRCalc++ Object Oriented Scripting Language by Adrix.NT
    « Last post by Thaddy on Today at 12:03:11 pm »
    Not interested. Filed under spam since it also showed up as a private message. Room 101 plz.
    9
    General / MOVED: VRCalc++ Object Oriented Scripting Language by Adrix.NT
    « Last post by marcov on Today at 11:56:04 am »
    This topic has been moved to Third party.

    http://forum.lazarus.freepascal.org/index.php?topic=35884.0
    10
    Third party / Re: Online Package Manager
    « Last post by GetMem on Today at 11:44:13 am »
    Quote
    Oops, sorry. I haven't been following the development all the time.
    Submit button sounds good. Makes contributing packages easier and thus more package maintainers will do it in future.
    Things are looking good so far. I received at least 10 package in the last month. New packages are highlighted with a blue lightning icon(see attachment).

    Quote
    I removed LazarusPackageManager in r54189.
    Thanks.
    Pages: [1] 2 3 ... 10

    Recent

    Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus