How Unit2 procedure result show in Main Unit1 form???? lazarus / 61-Beginners ---------------------------------------------------------------------- fiazhnd · 2017-05-18 08:10 My Code is becoming big so i decide to spread over different units so easy to read and update, Unit1 is my main page where i created the form and object, i have issue the result of 'A' want to show in Edit1 which is on Unit1 so compiler give error when compiler " Unknown identifier or variable is not declared: 'Edit1'." What i need to do so 'v4' result show in Edit1 which in Unit1? Unit1 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ReadClick(Sender: TObject);beginif ComboBox2.Text = ('A') then begin ImmoCodeRead('A') end; end; Unit2 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure ImmoCodeRead(logic: string);  beginif logic = ('A') then begin    v1:=(inttohex(GetByteHexEdit($60),2)+inttohex(GetByteHexEdit($61),2)+         inttohex(GetByteHexEdit($62),2)+inttohex(GetByteHexEdit($63),2));    v2:= StrToInt('$'+v1) xor $FABE8675    v3:= IntToHex(v2, 8);    v4:= chr(StrToInt('$'+v3[1]+v3[2]))+chr(StrToInt('$'+v3[3]+v3[4]))        +chr(StrToInt('$'+v3[5]+v3[6]))+chr(StrToInt('$'+v3[7]+v3[8]));     Edit1.Text:= (v4); end; ---------------------------------------------------------------------- Zoran · 2017-05-18 10:22 One way would be: Unit1: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ReadClick(Sender: TObject);begin  if ComboBox2.Text = ('A') then    Edit1.Text := ImmoCodeRead('A'); end; Unit2: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ImmoCodeRead(logic: string): String;begin  Result := '';  if logic = ('A') then begin    v1:=(inttohex(GetByteHexEdit($60),2)+inttohex(GetByteHexEdit($61),2)+         inttohex(GetByteHexEdit($62),2)+inttohex(GetByteHexEdit($63),2));    v2:= StrToInt('$'+v1) xor $FABE8675    v3:= IntToHex(v2, 8);    v4:= chr(StrToInt('$'+v3[1]+v3[2]))+chr(StrToInt('$'+v3[3]+v3[4]))        +chr(StrToInt('$'+v3[5]+v3[6]))+chr(StrToInt('$'+v3[7]+v3[8]));     Result := v4;  end;end; ---------------------------------------------------------------------- fiazhnd · 2017-05-18 10:54 Thank you Zoran, It work like charm and it save me from a lot of work.................. i was also working same type of syntax structure after i post here but one thing ( Result := ' ' is in your code can you explain to me this? One question is more what if i have multiple result need to show in multiple edit object? ---------------------------------------------------------------------- Zoran · 2017-05-18 13:07 Quote from: fiazhnd on May 18, 2017, 12:54:26 pmThank you Zoran, It work like charm and it save me from a lot of work.................. i was also working same type of syntax structure after i post here but one thing ( Result := ' ' is in your code can you explain to me this? Your function should return something if logic <> 'A' Quote from: fiazhnd on May 18, 2017, 12:54:26 pmOne question is more what if i have multiple result need to show in multiple edit object? You can use var or out parameters to return multiple results and then assign these to edits. https://www.freepascal.org/docs-html/ref/refsu65.html https://www.freepascal.org/docs-html/ref/refsu66.html https://www.thoughtco.com/return-multiple-values-from-delphi- function-1057664 http://wiki.freepascal.org/Variable_parameter ---------------------------------------------------------------------- fiazhnd · 2017-05-18 15:47 No luck with Var and Out parameter i know something wrong  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ReadClick(Sender: TObject);begin  if ComboBox2.Text = ('A') then begin ImmoCodeRead('B');Edit1.Text := ImmoCodeRead(v4);                                      Edit1.Text := ImmoCodeRead(vin);end;end;  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ImmoCodeRead(const logic: string out v4,Vin:String): String;begin  Result := '';  if logic = ('B') then begin    v1:=(inttohex(GetByteHexEdit($60),2)+inttohex(GetByteHexEdit($61),2)+         inttohex(GetByteHexEdit($62),2)+inttohex(GetByteHexEdit($63),2));    v2:= StrToInt('$'+v1) xor $FABE8675    v3:= IntToHex(v2, 8);    v4:= chr(StrToInt('$'+v3[1]+v3[2]))+chr(StrToInt('$'+v3[3]+v3[4]))        +chr(StrToInt('$'+v3[5]+v3[6]))+chr(StrToInt('$'+v3[7]+v3[8]));   Vin := '';   Address := $50   While Address <> $61 do Begin   Vin := Vin + chr(GetByteHexEdit(Address));   Address := Address +1 ;   end; Result := v4;Result := Vin;  end;end; ---------------------------------------------------------------------- molly · 2017-05-18 16:19 Try: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ReadClick(Sender: TObject);var  V4, VIn: String;begin  if ComboBox2.Text = ('A') then   begin     ImmoCodeRead('B', V4, VIn);   Edit1.Text := v4;   // In your original example/question you only wanted to have V4 displayed in Edit1.Text, now you are overwriting that text in Edit1 with vIn, in case you uncomment the next line.                                   //    Edit1.Text := vin;  end;end;  And there's more going wrong there. Seems you do not know the basics yet. Code: [Select]Result := v4; Result := Vin;  There is only one result in a function. The others values are returned using their (variable) name. In your specific case for function ImmoCodeRead that would be variables V4 and Vin The above does not imply you are not allowed to return a value by using the function result and a var/out parameter. Sometimes (as in your case) it seems redundant. Which bring the question why do you need a function ? e.g. you have to decide what you want to return where exactly first (in the result or var/out parameter) and act accordingly. BTW: your code makes no sense in whatever setup i know, you are using procedures while they should be procedures of object (at least ReadClick should). And i am guessing that you are messing up your (global) variables quite considerably with defining your parameter variables with the same name. edit: typo's edit2: comment ---------------------------------------------------------------------- fiazhnd · 2017-05-20 05:46 Thank you man its work i use var parameter and it return me two values work fine with me now