Page 1 of 1

Posted: 29 Dec 2009, 23:37
by manecante
hello

Pascal n00b question:
I cannot seem to find the correct type for ptTextField:

Code: Select all

...
filein := createParam('filename', ptTextField);
...
I was expecting to get a String with GetValue(filein) but I get a "type mismatch" error...
it seems that I get 1 single, which is an ASCII value of the 1st letter of the typed in text.

am I wrong assuming that it should be a String (or an array of ascii chars) ???

if yes, how can I get the value of the string entered in the textfield ?

cheers

Posted: 30 Dec 2009, 00:19
by bsork
Here's an example from a file I think is in the AddOns (TextFile2Data):

Code: Select all

...
VAR filename   : String;
...
PROCEDURE init;
BEGIN  
  ...
  pFilename := CreateParam('file name', ptTextField); SetIsOutput(pFilename, FALSE);
  ...
END; // init

PROCEDURE GetFileName;
  VAR i : integer;
  VAR c : String;
  VAR s : String;
BEGIN
  s := '';
  filename := GetStringValue(pFileName);
  FOR i := 1 TO (length(filename)) DO BEGIN
    c := copy(filename, i, 1);
    IF &#40;c <> '"'&#41; THEN
      s &#58;= s + c;
  END;
  filename &#58;= s;
  writeln&#40;'FileName&#58; ' + filename&#41;;
END; // GetFileName
...
Hope this helps.

Actually, I'm not 100% sure that you have to create a loop and copy the string one character at the time, but at least it works :)

Posted: 30 Dec 2009, 01:04
by manecante
hi bsork

great, this works perfectly !

and yes, you can avoid looping:

Code: Select all

var str_tmp &#58; String;
begin
     str_tmp &#58;= GetStringValue&#40;filein&#41;;
end;
but after a few hours of trying Pascal, it seems to me that you *have* to loop for about (nearly) everything :P

thanks again !

_yvan (obliged to write code by/for manecante)