Jump to content

grantful

Members
  • Content Count

    79
  • Joined

  • Last visited

Everything posted by grantful

  1. I am thinking of writing a new database table drinks table ingredients table directions i think this will be better to use it seems to be a problem to grab all the strIngredians1,stringrediants2 etc from the same table and show them in a memo
  2. There is 11 of the strIngrediants
  3. It is a SQLite database Example Table (Drinks) Fields idDrink,strDirections,stringrediants1,stringrediants2,stringrediants3,stringrediants4,etc so when I click on any record in the listview I need to use the idDrink (integer) and display all the fields idDrink field is int strdrink is string stringrediants1,stringrediants2,stringrediants3 is string so the strDirections will go into a memo the stringrediants3,2,3 etc will go in a memo
  4. Thanks for your help Stano it is 1 table(drinks) there are fields stringrediants1 stringrediants2 stringrediants3. Etc So when I click on the listview item I need to get the. Field. ‘IdDrink’ from the table and load up all the stringrediants1,stringrediants2,stringrediants3 etc. from the same table into a Listview or listbox,or memo Thanks for your patience and help
  5. Thanks so much I will look at this and the tutorial. I had made it this far. var DrinkID: Integer; begin FDQuery1.SQL.Text := ('Select * From drinks Where idDrink = :_idDrink'); // showMessage (intToStr(fdquery1.FieldByName('idDrink').AsInteger)); FDQuery1.ParamByName('_idDrink').AsString := (TListViewItem(lvDrinksListview.Items.Item [lvDrinksListview.ItemIndex]).Text); // // strToInt(TListViewItem(lvDrinksListview.Items.Item[lvDrinksListview.ItemIndex]).Text) ; FDQuery1.Open; momoDrinkIngrediants.Lines.Add(FDQuery1.FieldByName('strIngredient1') .AsString); momoDrinkIngrediants.Lines.Add(FDQuery1.FieldByName('strIngredient2') .AsString); FDQuery1.Next; TabControl1.ActiveTab := tiDrinksIngreediantsAndDirections; FDQuery1.Close; end; // ShowMessage(TListViewItem(lvDrinksListview.Items.Item[lvDrinksListview.ItemIndex]).Text); // ShowMessage(TListViewItem(lvDrinksListview.Items.Item[lvDrinksListview.ItemIndex]).Detail);
  6. @Stano Thanks for your patience. I have not worked with objects before. I took your advice and renamed some things. type TMyObject = class(TObject); procedure TForm2.lvDrinksListviewItemClick(const Sender: TObject; const AItem: TListViewItem); var idDrink: TMyObject; begin idDrink := TMyObject.Create; /// / It has nothing to do here!!! /// It's supposed to be where you create FDQuery1 /// A separate function. For all Query FDQuery1.SQL.Text := ('Select strDrink,idDrink From drinks Where strDrinks = :idDrink'); /// Something like that FDQuery1.ParamByName('IDDRINK').AsInteger := idDrink(lvDrinksListview.Items.Objects[lvDrinksListview.ItemIndex]).Value; try FDQuery1.Open while not FDQuery1.Eof do begin /// Tu niečo urobíš FDQuery1.Next; end; TabControl1.ActiveTab := TabItem8; finally FDQuery1.Close; end; [dcc64 Error] uMain.pas(517): E2003 Undeclared identifier: 'Objects' [dcc64 Error] uMain.pas(517): E2003 Undeclared identifier: 'Value' I am using Delphi 11 community edition. This is and FMX multi device program. Can you perhaps tell me what i am doing wrong ? Thanks again for all the help.
  7. Thanks for all your help and your tutorails. I was trying to use the query for the listview. FDQuery1.ParamByName('idDrink').asinteger := (listview2.Items.Item[listview2.ItemIndex].detail); this is where i was trying to fix the problem. Im sure some years back i did something like this and this line worked FDQuery1.ParamByName('idDrink').asinteger := (listview2.Items.Item[listview2.ItemIndex].detail); but now i am getting problems with this error [dcc64 Error] uMain.pas(627): E2003 Undeclared identifier: 'detail' I am looking into useing the live bindings https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_Custom_Format_and_Parse_Expressions_in_LiveBindings#Binding_Expressions I would like to figure out this problem with my code. Thanks for any help and any help with the query code.
  8. @Serge_G Very informative tutorial. I learned alot from it. I have a question about binding multiple fields to the same memo. I need to bind all of the stringrediants1,2,3 ect to the same memo. Do you have any more tutorials that might help with this or is there a way to do it you have not made a tutorial ?? Thanks for the help i really appreciate it.
  9. Thanks for all the comments. I will look into the tutorial.
  10. Thanks for your help i will try it out
  11. i am trying with a listview but now luck. procedure TForm2.ListView2ItemClick(const Sender: TObject; const AItem: TListViewItem); begin FDQuery1.Active := True; while not FDQuery1.Eof do begin fdquery1.SQL.Clear; FDQuery1.SQL.Text := ('Select strDrink,idDrink From drinks Where strDrinks = :idDrink'); if ListView2.ItemIndex >= 0 then begin FDQuery1.ParamByName('idDrink').asinteger := (listview2.Items.Item[listview2.ItemIndex].detail); FDQuery1.Open; FDQuery1.Next; end; TabControl1.ActiveTab := TabItem8; end; end; i get an error at detail [dcc64 Error] uMain.pas(470): E2003 Undeclared identifier: 'detail'
  12. do you have a link to a tutorial ? I need to figure this out
  13. grantful

    MatchText partial string match

    I am trying to find a string with MatchText. example if "grant" is in the array and i type exactly "grant' it will find it. I want to search the string array with a part of the string example 'gr' and have it return all the text that has gr in it. Thanks for any help.
  14. I have a local drink list in a local file . ( drinks.json) does anyone know how i can load it into a fdmemtable or something to work with the jasonfile ? I was trying to rightclick on the memtable and load from file but i get an error even if i use delphis sample json files. has anyone else had a similar problem with the memtable Thanks for any help.
  15. grantful

    load a local json file into my app, (fdMemTable, etc)

    Hey thanks for the help. I will look into this.
  16. grantful

    Remove quotes from a string

    I am doing a json query and getting the objects the strings i am getting back have quotes around them example "bloody mary", "Mararita", "old fasion", etc I am using the split finction to remove the quotes and it works gooed My problem is when i load the strings into a listbox or memo it get an item and then 2 spaces , an items and 2 more spaces, etc Has anyone run into this problem ? As always thanks for any help and comments.
  17. grantful

    Remove quotes from a string

    SrcString := (JSONValue as TJSONObject).GetValue('strDrink').AsType<string>; this fixed it. Thanks for all your guys help and time.
  18. grantful

    Remove quotes from a string

    Thanks for the comments. I can not believe i forgot to show the code 😞 procedure TForm2.findReciepeClick(Sender: TObject); const Delim: String = '"'; var MainJson, Result: TJSONObject; reslultListbox: TJSONArray; s: TArray<string>; SrcString: String ; begin Form2.RESTClient1.BaseURL := 'https://www.thecocktaildb.com/api/json/v1/1/search.php?s=' + Edit7.Text; Form2.RESTRequest1.Execute; Memo4.Text := Form2.RESTResponse1.JSONText; Result := TJSONObject.ParseJSONValue(Form2.RESTResponse1.Content) as TJSONObject; reslultListbox := Result.GetValue('drinks') as TJSONArray; for var JSONValue in reslultListbox do begin SrcString := (JSONValue as TJSONObject).GetValue('strDrink').ToString; s := SrcString.Split(Delim); ListBox1.Items.AddStrings(s); end; MainJson := Result.GetValue<TJSONObject>('drinks[0]'); Edit8.Text := MainJson.GetValue<string>('strDrink'); MainJson := Result.GetValue<TJSONObject>('drinks[0]'); Memo5.Text := MainJson.GetValue<string>('strInstructions'); end;
  19. grantful

    Jason array into a listbox

    I am getting a json response from here http://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita The response has different drinks for margarita. I can pick the fist drink info just fine . I am trying to loop through the drinks and load then in an array and put the array into a listbox so i can choose which drink i want to look at. var MainJson, Result: TJSONObject; s: String; i: integer; relultListbox: TJSONArray; begin Form2.RESTClient1.BaseURL := 'https://www.thecocktaildb.com/api/json/v1/1/search.php?s=' + Edit7.Text; Form2.RESTRequest1.Execute; Memo4.Text := Form2.RESTResponse1.JSONText; Result := TJSONObject.ParseJSONValue(Form2.RESTResponse1.Content) as TJSONObject; relultListbox := TJSONObject.ParseJSONValue(Form2.RESTResponse1.Content) as TJSONArray; for I := 0 to relultListbox.Size - 1 do begin ListBox1.Items.Add(relultListbox.Items[I].Value); end; MainJson := Result.GetValue<TJSONObject>('drinks[0]'); Edit8.Text := MainJson.GetValue<string>('strDrink'); MainJson := Result.GetValue<TJSONObject>('drinks[1]'); Memo5.Text := MainJson.GetValue<string>('strInstructions'); relultListbox := TJSONObject.ParseJSONValue(Form2.RESTResponse1.Content) as TJSONArray; for I := 0 to relultListbox.Size - 1 do begin ListBox1.Items.Add(relultListbox.Items[I].Value); end; I am getting invalid class typecast. I am not sure if i need to load the json into an array. Thanks for any help with this.
  20. grantful

    Jason array into a listbox

    Thanks for pointing me in the right direction. Here is working code for anyone who may need to do the same thing uses system.json; var MainJson, Result: TJSONObject; reslultListbox: TJSONArray; begin Form2.RESTClient1.BaseURL := 'https://www.thecocktaildb.com/api/json/v1/1/search.php?s=' + Edit7.Text; Form2.RESTRequest1.Execute; Memo4.Text := Form2.RESTResponse1.JSONText; Result := TJSONObject.ParseJSONValue(Form2.RESTResponse1.Content) as TJSONObject; reslultListbox := Result.GetValue('drinks') as TJSONArray; // reslultListbox:= TJSONObject.ParseJSONValue('drinks') as TJSONArray; for var JSONValue in reslultListbox do begin ListBox1.Items.Add((JSONValue as TJSONObject).GetValue('strDrink') .ToString); end; MainJson := Result.GetValue<TJSONObject>('drinks[0]'); Edit8.Text := MainJson.GetValue<string>('strDrink'); MainJson := Result.GetValue<TJSONObject>('drinks[0]'); Memo5.Text := MainJson.GetValue<string>('strInstructions');
  21. grantful

    FMX Tabcontrol Tab Hight

    Thanks so much for the help i will try this.
  22. grantful

    FMX Tabcontrol Tab Hight

    I did go and uncheck the autosize on each tab item. I can see the change now in the ide but when i install on ios and android it still is small. Any thoughts ? Thanks for the help
  23. grantful

    FMX Tabcontrol Tab Hight

    Thanks Dave. I dont know how i missed that 🙂
  24. grantful

    Load image from splite blob field

    I am trying to load a image from a sqlite database field tfdQuery sql is select camarapic from photos Procedure LoadBitmapFromBlob(Bitmap: TBitmap; Blob: TBlobField); var ms, ms2: TMemoryStream; begin ms := TMemoryStream.Create; try Blob.SaveToStream(ms); ms.Position := 0; Bitmap.LoadFromStream(ms); finally ms.Free; end; end; procedure TCustomerInfo.SpeedButton6Click(Sender: TObject); var bmp: TBitmap; begin bmp := TBitmap.Create; try //datamodule2.InsertImg.SQL:=('select camarapic form photos where cusid : 2'); LoadBitmapFromBlob(bmp, TBlobField(datamodule2.InsertImg.FieldByName('camarapic'))); Image2.Bitmap.Assign(bmp); finally bmp.Free; end; end; When i run the app the image2 just goes blank Thanks for any help.
  25. grantful

    Load image from splite blob field

    Thanks so much for the help. It works great
×