Welcome, Guest. Please login or register.

Author Topic: Executing c command in c  (Read 10459 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Executing c command in c
« on: May 07, 2017, 07:19:44 PM »
Hi
Can anybody explain how in Amiga C I can use Execute() but change the directory first. I thought it would be simply Execute("cd path",bptr,bptr); but that is ignored
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #1 on: May 07, 2017, 11:31:58 PM »
Thanks.

I've looked for information on the SystemTagList() but can't find much that I understand.
I've tried to use it but I'm just getting a crash.
Heres what I've got with an explanation of why I think it's supposed to be like this. Though probably doing it completely wrong.
Code: [Select]

   struct TagItem * tags;            /*Setup a pointer to the tags that will be used */
   tags = AllocateTagItems(1);    /*Create empty tag*/
   tags[0].ti_Tag = NP_CurrentDir;  /*Set Tag as NP_CurrentDir */
   tags[0].ti_Data = (ULONG)"work:/docs/";  /*Set the directory path prefixed with (ULONG) because ti_Data only accepts ULONG %/
   SystemTagList("dir",tags);  /*Runs the command dir in tags[0] (not the command I'm actually running but used in this instance to shorten code */
   FreeTagItems(tags);   /*Clear tags from memory*/


Sorry if this is all actually simple stuff. A lot of the sites I'm finding for tutorials are either dead sites, not in depth enough to explain things properly or not in English and when I translate the text using google translate the code gets messed up and no longer works.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #2 on: May 08, 2017, 09:42:35 AM »
Thanks again Thomas.
Didn't find anything like that when I was trying to see how to use it. You have been a big help.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #3 on: May 08, 2017, 08:45:24 PM »
Thomas I tried using the method you posted but it didn't work.
It gave me an error on the lock bit of system()
So I mixed what I already had by using a lock and not a string and it worked.
Thank you for pointing me in the right direction.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #4 on: May 09, 2017, 01:54:01 PM »
Yeah that's how I had it except I didn't use SHARED_LOCK . My documentation only talked about read_access and write_access so I used read_access.

I'm not sure I tried SystemTags(). I tried System() and SystemTagList() .

I notice your code uses (int argc,char **argv) . Is this important as I haven't included them?
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #5 on: May 10, 2017, 09:22:41 AM »
Good to know thanks.

I'm starting to think I might give up or change language as I'm just not finding anything that I is useful to help me understand what to do. Except for the help here which was great.

For example I'm now trying to open a jpg picture in mui.
I found how to play a sound in mui but nothing about pictures.
I found one tutorial that says how to create a datatype object but nothing on how to set that object as a picture or how to display said picture in a window.
I looked at mui_image. I think I have to use the OLD_Image attribute because I didn't see anywhere else to set the image.

I've managed to create a listview with a list that is loaded from a file and when I double click an item in the list it runs an event (Currently shows me the contents of the directory of where the file is stored in the console). I tried to find information on how to do something for a single click .
The only thing I can find that seems to make sense is select_change (https://muidev.de/wiki/Documentation/API/MUI_Listview#MUIA_Listview_SelectChange)
but this only works if I hold the mouse button down and drag it up and down the list.

So I'm thinking it's either keep asking lots of questions here or just give up and as I don't want to annoy people with my questions I'm leaning towards the give up. :(
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #6 on: May 10, 2017, 04:38:19 PM »
With regards to the image I'm trying to load
Do I create an area as a child of the window and then DTpic as a child of the area with MUIA_Dtpic_Name holding the filename (pointer to the string) for the image I want to open?

Will the datatypes library then work out what type of picture it is (iff,png,jpg,etc) or does that need to be specified somewhere else?


Will the list selection on a single click be something like
Code: [Select]
DoMethod(List_Name, MUIM_List_Select, MUIV_List_Select_Active, MUIV_List_Select_Ask, TRUE, Action_Name);  (Where list_name is the name of the list and Action_Name is the name of the called function)
« Last Edit: May 10, 2017, 04:53:00 PM by foleyjo »
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #7 on: May 10, 2017, 09:45:26 PM »
Thanks for the advice nicholas though were the 2 links supposed to be to the same site.
I did find that site but I was looking through an example I downloaded from it but the comments were not in English.

I managed to get an image loaded using Dtpic.
It wasn't working earlier but I think I was using an old version of mui as I downloaded the latest from muidev.de and Dtpic worked.

There's also some demos in this version that I didn't have which seem to do things that I need so I can try and learn the code.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #8 on: May 10, 2017, 11:26:49 PM »
Haha I thought it was strange they both linked to the same page.
. I'll have a read through those other sites tomorrow.

I looked at Hollywood but I read somewhere that it doesn't allow you to launch external programs which is why I avoided it as its something I need.


I've managed to get images changing with a single click now using

Code: [Select]

DoMethod(list, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
app, 2,
MUIM_Application_ReturnID, DISPLAY);
   
Where DISPLAY contains a set attributes function on my DtPic object.

So I think I'm going to keep trying for a bit.
I should have enough information now to help me understand what I'm doing :D
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #9 on: May 11, 2017, 06:27:29 AM »
Oh no way. If I knew that would have looked into getting hollywood as it looks much easier.

If I get stuck again I'll definitely consider changing to it.
For now I'll just convince myself I made the right choice because I'm learning useful things.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #10 on: May 18, 2017, 08:13:21 AM »
Me again :D

Thanks to the advice I received here I have made lots of progress.
I'm still getting things wrong but understand enough to make corrections.
I also understand more about MUI and can work out how to make it do what I want.
I have hit a small stumbling block though.

How do you get the string value from a mui_popstring popup object? So say I wanted the user to select a file and then save the filename to a string what command would I use?

Also what are APTRs and BPTRS, Should I be using them or is it fine to stick with Object * ?
The reason I ask is because the tutorials I used at first had Object * but when I was looking at the mui examples they used APTR. I think APTR looks nicer in the code .

I'm hoping to have something to show soon. (famous last words)
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #11 on: May 18, 2017, 10:14:51 AM »
So if I understand you right....
I don't need to worry about BPTR unless I'm using a predefined function that takes or returns a BPTR (which will usually be dos functions such as the Lock one I'm using)

APTRs I assume it's more of a preference thing. So I could use char * or APTR when declaring a string pointer and not expect much difference.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #12 on: May 18, 2017, 11:44:33 AM »
Thanks Olsen,
I understand what they are now.
I decided against using APTR for the reasons you said. I'm making too many rookie mistakes at the moment and luckily the compiler is catching them. If it didn't I'd have lots more problems.
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: Executing c command in c
« Reply #13 on: May 18, 2017, 01:13:25 PM »
haha tell me about it. Spent a couple of hours last night trying to resolve errors.

I was either being told I needed a ; after an end on one of the lines or would just get 100s of errors.
Turned out the problem was a missing comma further up the page
 

Offline foleyjoTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 608
    • Show all replies
Re: General C help
« Reply #14 on: May 19, 2017, 08:57:11 AM »
Well Olsen and Thomas thanks to your explanations about APTRs and BPTRs something clicked and I was able to work out how to get the string value from the mui_pop_string.

The talk of pointers, objects and strings made me realise that muia_popstring_string was returning a mui string object and not a string so I retrieved the value in 2 parts.

First I did a get() on the pop object to get the popstring_string object and then did another get on the returned object to get the strings content.

So now I think I understand everything I need to to get my first program completed without having to ask anymore questions.
There's still some stuff that I don't understand such as hooks but I think I'll be able to avoid creating any of my own.

So hopefully I won't be bothering anyone for help and advice till I have something to show.

You guys have helped point me in the right direction and understand so much more than all the guides and tutorials I spent weeks on and the reason why I always return to Amiga.org when I have an Amiga related question.

Cheers :D