English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 24 June 2023, 05:19   #1
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
LISTVIEW_KIND exec lists

Forgive me but I've clear forgotten how to use this gadget; SASC 6.58, would be good if there was a repository some place with example code on how to do some of these things just as a branching thought.

Code:
  
  struct NewGadget ng;
  struct List *diskList;
  

  if (diskList = AllocMem(sizeof(struct List), MEMF_CLEAR)) {
    NewList(diskList);

  } else {
    printf("Cannot allocate memory for list.\n");
  }

  gad = CreateContext(glistptr);

  ng.ng_LeftEdge   = 4;
  ng.ng_TopEdge    = 4;
  ng.ng_Width      = 200;
  ng.ng_Height     = 200;
  //ng.ng_GadgetText = "_+";
  ng.ng_GadgetID   = LV_DISKS;
  ng.ng_Flags      = 0;
  gad = CreateGadget(LISTVIEW_KIND, gad, &ng,
                     GTLV_ShowSelected, NULL,
                     GTLV_Selected, 0,
                     GTLV_MakeVisible, 0,
                     GTLV_Labels, diskList, 
                     TAG_END);
I'm forgetting something, I get suspend / reboot #80000005 (integer division by zero error.)
Inner200k is offline  
Old 24 June 2023, 08:47   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,044
GTLV_Labels tag is an array of pointers (struct List*[]) and not a single struct List*. Something like:
Code:
struct List lab0 = { ... };
...
struct List lab3 = { ... };
struct List* disklist[4] = { &lab0, ..., &lab3 };
a/b is offline  
Old 24 June 2023, 10:00   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,019
Quote:
Originally Posted by Inner200k View Post
I'm forgetting something, I get suspend / reboot #80000005 (integer division by zero error.)
You should ignore a/b's post, it's complete nonsense.

Your code looks ok. Which version of gadtools.library are you using?

The list is completely empty, but you still ask it to select the first entry and make it visible. Maybe you should add some nodes to the list. Or omit these tags until the entry you ask for is actually in the list.

There is a rather old example: http://thomas-rapp.homepage.t-online.de/examples/lv.c
I don't know if it covers your issue here.
thomas is offline  
Old 24 June 2023, 13:25   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,044
I meant array of nodes, of course. That should make a little more sense but it's still wrong (struct List* is the correct tag argument).
The problem was my "source of info" (a pretty big and messy one, shouldn't be hard to guess :P) is not using a list header (c equivalent: struct List, with extra type and pad) but a minimal list header (struct MinList, containing only 3 pointers), which is easily mixed up with a pointer array when you have DC.L's. Combined with settings the labels for other gadgets (radio buttons, multi select buttons) that do have a GTXX_Labels pointer array argument...
In any case, thanks for correction.
a/b is offline  
Old 24 June 2023, 16:02   #5
Inner200k
Registered User
 
Join Date: May 2023
Location: Christchurch, New Zealand
Posts: 33
Quote:
Originally Posted by thomas View Post
You should ignore a/b's post, it's complete nonsense.

Your code looks ok. Which version of gadtools.library are you using?

The list is completely empty, but you still ask it to select the first entry and make it visible. Maybe you should add some nodes to the list. Or omit these tags until the entry you ask for is actually in the list.

There is a rather old example: http://thomas-rapp.homepage.t-online.de/examples/lv.c
I don't know if it covers your issue here.
v37 it's a framework from an example I found for doing sliders / string & buttons and such, since I knew what was trying to do rather than reinvent the wheel, I used what was there modifying it and removing parts I didn't require, hmm considering I've got gadtools.library version 40.5 maybe I should change that as I doubt many well be running 37 these days if any, however I suppose it doesn't really matter for now?

Yes the list is 'supposed' to be empty for now, program start presents an empty list to be filled by the user later, a collection of disk image(s) names to be exact.

-- source code compiles at least had to add a few includes but it runs, now to to discover why it runs.

Last edited by Inner200k; 24 June 2023 at 16:13.
Inner200k is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
WHDLoad and exec Radertified Coders. Asm / Hardware 2 16 August 2021 15:36
How to know if user really clicked an option in a LISTVIEW_KIND gadget? Sim085 Coders. General 6 16 July 2021 15:28
Exec style Devices bloodline Coders. System 23 30 November 2020 20:17
#LISTVIEW_KIND gadget and keyboard + mouse peceha Coders. Blitz Basic 2 15 August 2018 11:26
CDTV exec.library Arnie support.WinUAE 19 18 February 2016 13:11

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:27.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06990 seconds with 13 queries