Forum > General

[SOLVED] Type conversion?

<< < (2/4) > >>

Zvoni:
This not making any sense.
Acc. to documentation, ReadStr works like Read, but without a File.
In this case ts being the "File", and anIT the "Target"

dje:
Packenum seems to fix it. Maybe look into that.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$PACKENUM 4}
https://www.freepascal.org/docs-html/prog/progsu59.html

--- Quote ---The default enumeration size depends on the compiler mode:

    In Delphi and TP mode, the size is 1.
    In MacPas mode, the size is 2.
    In all other modes, the default is 4.
--- End quote ---

MarkMLl:

--- Quote from: Zvoni on August 15, 2022, 12:54:02 pm ---This not making any sense.
Acc. to documentation, ReadStr works like Read, but without a File.
In this case ts being the "File", and anIT the "Target"

--- End quote ---

The only useful bit in the documentation is the example, which shows a string being written to a temporary textfile using Write() and then parsed into multiple elements using Read(). For some small value of "useful" :-/

So the first parameter of ReadStr() is a (constant) string, and the non-first are values of types acceptable to the RTL to be parsed out of it. In theory, at least :-/

MarkMLl

egsuh:
Thank you for your advices.  This compiles in {$mode objfpc}.
Haven't tested running yet. I'll post the result.

egsuh:
I have tested this which works as expected.  To add some more explanation, I'm trying this to save the whole option as TStringList.  As you can see in the following codes, one CodeOption corresponds to an Input of HTML Dom. I'd like to define HTML inputs programmatically, and users are able to edit the attributes of the inputs in my Lazarus program, using TIPropertyGrid.

The content is saved as text, TCodeOptions.Text, in DB.  I'm trying to reduce my own code writings.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TInputTypes = (itText, itPassWord, itRadio, itCheckbox, itHidden, itTel,                 itNumber, itUrl, itEmail, itRange, itDate, itMonth, itWeek);   TCodeOptions = class (TStringList)  private     function getInputType: TInputTypes;     function getIntegerOption(AIndex: Integer): integer;     function getRequired: Boolean;     function getStringOption(AIndex: Integer): string;     procedure setInputType(AValue: TInputTypes);     procedure setIntegerOption(AIndex: Integer; AValue: integer);     procedure setRequired(AValue: Boolean);     procedure setStringOption(AIndex: Integer; AValue: string);  published     // HTML input attributes     property InputType: TInputTypes read getInputType write setInputType;     property Pattern: string     index 2 read getStringOption write setStringOption;     property PlaceHolder: string index 3 read getStringOption write setStringOption;     property Title: string       index 4 read getStringOption write setStringOption;      property Required: Boolean read getRequired write setRequired;     property MinLength: integer index 1 read getIntegerOption write setIntegerOption;      property Min: integer index 11 read getIntegerOption write setIntegerOption;     property Max: integer index 12 read getIntegerOption write setIntegerOption;     property Step: integer index 13 read getIntegerOption write setIntegerOption;      // Custom options     property PreText: string index 101 read getStringOption write setStringOption;     property PostText: string index 102 read getStringOption write setStringOption;  end; 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version