-2

i,m working on my first delphi script and when i want to run it there is an '; expected' error but i dont know why. When i click on the error the cursor jumps to the location where the error appears but that's two lines below the end of the code What's wrong?

var   
   stringName : String;
   stringBase : String;         

procedure setPicturePath();
var      
    qryPicEncode : TOraQuery;
    qryPicDecode : TOraQuery; 
begin
    qryPicEncode := TOraQuery.Create(nil);
    qryPicEncode.SQL.Text := 'select ''utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw("werner weilenmann"))) from dual';
    qryPicDecode := TOraQuery.Create(nil);
    qryPicDecode.SQL.Text := 'select ''utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw("d2VybmVyIHdlaWxlbm1hbm4="))) from dual';                                                    

    qryPicEncode.open;
    qryPicEncode.first;
    if not(qryPicEncode.eof) then begin
        stringName := qryPicEncode.fieldByName('pic4Path').AsString;
    end;
    qryPicDecode.open;
    qryPicDecode.first;
    if not(qryPicDecode.eof) then begin
       stringBase := qryPicDecode.fieldByName('ODACQuery1').AsString;
    end;
    qryPicEncode:=nil;              
    qryPicDecode:=nil;                                         
end;  


begin
    //Picture2.LoadFromFile('U:\Documents\logos\logo1.png');              
    setPicturePath();
    showmessage(stringName);
    showmessage(stringBase);          
end.
DoFlamingo
  • 232
  • 1
  • 18
  • You haven't shown enough code to answer what's causing the `; expected` error. Since the compiler thinks the error is past your actual code, it maybe that you have wrong End-Of-Line characters in parts of your code. This may happen when you copy code from the net. Which Delphi version are you working with? – Tom Brunberg Oct 21 '19 at 10:15
  • 2
    There seem to be some other errors too. In the lower `begin - end` block you call `setPicturePath` which on its end sets `qryPicEncode:=nil` and `qryPicDecode:=nil`. At the time the execution returns to the lower `begin - end` block, your code continues with a call to `showmessage(qryPicEncode);`. What do you expect the `ShowMessage()` dialog to show you? Secondly, `qryPicEncode` and 'qryPicDecode' are local variables in `procedure setPicturePath`, they are not even visible to the lower `begin - end` block. – Tom Brunberg Oct 21 '19 at 10:15
  • Take a look at [this answer](https://stackoverflow.com/a/53360447/2292722) for an explanation when a wrong End-Of.Line character may offset line numbers of code. It explains it in conjunction of the executable lines (where breakpoints may be put) , but causes similar line number errors otherwise too. – Tom Brunberg Oct 21 '19 at 10:26
  • i've edit it and now i get a 'quoted string not properly terminated' exception. – DoFlamingo Oct 21 '19 at 10:55
  • i want to display the name Base64 encoded and decoded – DoFlamingo Oct 21 '19 at 10:56
  • You did not yet answer which Delphi version you are using! I see you changed the last `end;` to a `end.` (with period instead of semicolon). Did it fix the `; expected` error?. That would tell me you are writing a console program, is that right? Regarding `Quoted string ...`, please consider that SO is not an ongoing debugging help service. You can not continue with the same question as new problems pop up. Elementary syntax errors should be solved by looking at the documentation. – Tom Brunberg Oct 21 '19 at 11:15
  • I don't see any selection from the database of fields named _pic4Path_ or _ODACQuery1_. I would therefore expect you to get an error in your two calls to _FieldByName_ that the field you are trying to access does not exist. You need to provide a fully compilable and testable example, otherwise we can continue to point out errors in your code till the cows go home... :-) – HeartWare Oct 21 '19 at 11:24
  • i have a test-tabel this script is written n Fast-Report where i can add test-querys – DoFlamingo Oct 21 '19 at 11:29
  • Is this delphi, and if not, what is it? – David Heffernan Oct 21 '19 at 13:56
  • yes this is delphi in the fast-report tool. You can generate report which are coded in delphi. But i've solved my problem – DoFlamingo Oct 21 '19 at 14:04

1 Answers1

1

Seems you have some errors with begin/end's.

Here:

begin
    setPicturePath();
    showmessage(qryPicEncode);
    showmessage(qryPicDecode);                                      
end;

you refer to variable qryPicEncode local to setPicturePath(); procedure - but this code chunk is outside of it...

Format source to reveal mistakes

MBo
  • 77,366
  • 5
  • 53
  • 86