14 May 2017, 22:15 | #21 | |||
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Huge thanks for all the help once again.
Quote:
Quote:
Quote:
<sigh> (there should be an Emogi for this the number of times I use it) Printf/printf Close/close... I thought that I'd left case sensitivity behind with Linux (or is it linux?) Many thanks for spotting this. And thanks again for all the help. |
|||
15 May 2017, 01:53 | #22 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
Code:
#include <proto/dos.h> int main(int argc, char *argv[]) { struct FileInfoBlock __aligned fib; BPTR f; if (f = Open("c:list", MODE_OLDFILE)) { if (ExamineFH(f, &fib)) { Printf("Size of c:list is %ld\n", fib.fib_Size); } Close(f); } return 0; } Code:
m68k-amigaos-gcc -noixemul -o fib fib.c |
|
15 May 2017, 15:07 | #23 | |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
Quote:
@Thread: I'm also a big fan of ReadArgs() - it's simply Amiga style. |
|
15 May 2017, 15:19 | #24 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
While it's useful, it's still not as good as a custom function can be, AOS style or not (don't care much about that other than not needing huge hacks like ixemul, and making sure things play nice with the OS).
|
15 May 2017, 15:26 | #25 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Not as good as a custom fonction ? There aren't many cases where it can't do the job. Often you need to perform extra checks of course, but it does most of the work. Do you have examples where ReadArgs isn't good enough ?
|
15 May 2017, 15:34 | #26 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
My only problem with ReadArgs() so far has been the fact it's a Kick2.x+-function (well, there is some unofficial method to use it with 1.3+) and sometimes support for 1.x is mandatory, resulting in a special 1.x binary with stripped down arguments.
|
15 May 2017, 20:56 | #27 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
|
15 May 2017, 22:11 | #28 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
18 May 2017, 16:33 | #29 |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Hi Again,
The ReadArgs vs Argv/Argc discussion is interesting and if I was not trying to get my executable down in size I would go the Argv/c route however I suspect (please correct if I am wrong) that one of the reasons it is so big is due to my using stdio. (?) Anyway I'm back with another stupid problem. This is in the code I am using to allocate the messages read in the file opened in my previous posts (the closing rather than Closing of which caused the guru) to an array of pointers so that I can then display them in the main output. My 1st effort was this line Code:
if (mess1=="msg_readwrite") {messages[0]=mess2;err=0;} /*change the read write message to that of prefs file*/ Code:
static char *messages[50]={MSG_READWRITE,MSG_NODISK,MSG_BADDISK,MSG_KICKSTART,MSG_NOT_DOS,MSG_READONLY,MSG_VALIDATING,\ MSG_MOUNTED,MSG_VOL_HEAD,"Unit","Size","Used","Free","Errors","Status","Name",MSG_ERROR_MEM,MSG_BREAK,\ MSG_ERROR_LIB}; The top of the function is as follows and it just contains a series of such if statements.. Code:
/*function to localise messages*/ int update_message(char mess1[], char mess2[]) { int err=1; int sizedef=-1; This compiles fine, but results in all the messages being the very last message in the prefs file, which is currently msg_size_t=Tb, so everything in the array messages =Tb. However what I want is for each element in messages to point to the memory location of the new message, passed as mess2, which I malloc'd in readprefs in effect changing the message to the new one. I've tried various combinations of Code:
if (mess1=="msg_readwrite") {&messages[0]=&mess2;err=0;} /*change the read write message to that of prefs file*/ Code:
if (mess1=="msg_readwrite") {messages[0]=&mess2;err=0;} /*change the read write message to that of prefs file*/ I must be getting confused about how pointers work, but can't find out quite work out where I am going wrong. |
18 May 2017, 17:14 | #30 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
You can't use == to compare strings in C. You need to use strcmp() for that.
|
18 May 2017, 17:28 | #31 |
Registered User
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,341
|
Just to explain in more detail - when you do use == to compare strings, you are actually comparing the values of the pointers (memory addresses). This is a perfectly valid thing to do, but not useful towards your goal here.
|
18 May 2017, 18:51 | #32 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
Quote:
Quote:
Indeed, you'd need a hash table to use pointer based string comparisons. |
||
18 May 2017, 20:22 | #33 |
Amigan
Join Date: Feb 2012
Location: London
Posts: 1,309
|
ReadArgs() can also be used to parse files. I believe RoadShow uses it for the config files (at least they use the same syntax). I like this!
|
19 May 2017, 00:35 | #34 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
Since programmers hate handling user input and writing help texts, ReadArgs is a great mediator between the programmer and user.
|
23 May 2017, 16:19 | #35 |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Hi again,
I have run into an odd problem which is affecting my code - and the original info command. To hit it you have to do the following. Have crossdos active on DF0: (so you have PC0:) Put an Amiga formatted floppy disk in df0: Format this as a PC disk using PC0: without removing the disk or anything else, open a shell and type info - you'll get something like this - Code:
Mounted disks: Unit Size Used Free Full Errs Status Name SMBFS0: 280M494895104529088512 2% 0 Read/Write PCbackup PC0: 720K 22 1418 2% 0 Read/Write EMPTY CF0: No disk present RAM: 612K 612 0 100% 0 Read/Write Ram Disk DH0: 94M 188030 5297 97% 0 Read/Write WB DF0: 837K 2 1756 0% 0 Read/Write Empty CC0: No disk present DF1: No disk present DH1: -639321K 6867197 242769 97% 0 Read/Write Games DH2: -540681K 7142379 164868 98% 0 Read/Write Apps Volumes available: EMPTY [Mounted] Empty [Mounted] PCbackup [Mounted] Ram Disk [Mounted] Apps [Mounted] Games [Mounted] WB [Mounted] I think the problem is that the format command is not refreshing the dos info once it is completed, or something else is not refreshing it. If you remove and re-insert the floppy then the system refreshes as you would expect and info reports correctly. Can anyone think of a way around this? Is there a way of forcing a dos refresh? Thanks in advance. |
23 May 2017, 19:45 | #36 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Untested.
Try Code:
Inhibit("df0:",TRUE); Inhibit("df0:",FALSE); Inhibit("pc0:",TRUE); Inhibit("pc0:",FALSE); http://amigadev.elowar.com/read/ADCD.../node017E.html |
23 May 2017, 19:54 | #37 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
Diskchange df0:
|
28 May 2017, 17:08 | #38 |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Thanks to all the great help folks have given I am nearing the end of my 'quest' to re-write the info command. I still have a looong way to go to be able to programme effectively in C but am getting there.
Anyway thanks to Thorham's post on the 1st page I now have a list of the reddest, bluest and greenest colours available on the users workbench screen. But (you could feel that coming I guess) I have hit another hurdle in that I can't for the life of me work out how to change the text colour in the shell window to equal them. It looks like the shell uses escape codes and also that it is limited to the number of colours it can use, is this the case? If so is there any way to get it to change the text to say colour 15 on a 32 colour screen? I read about the Write command here - http://amigadev.elowar.com/read/ADCD.../node0102.html And didn't understand it at all - other than the escape codes bit. Could someone point me at a nice - simple - example of changing the text colours in the shell window to one available on the workbench screen? I hope this is possible, as always many thanks in advance. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
general questions about assembler | Joe Maroni | Coders. General | 8 | 10 November 2010 12:39 |
General GBA questions | made | project.MAGE | 0 | 27 March 2009 16:24 |
General OS3.9 Questions | Marcuz | support.Apps | 9 | 05 September 2008 11:29 |
Two general questions about HOL | Tim Janssen | HOL suggestions and feedback | 3 | 25 March 2003 10:10 |
Some general newbie questions | Pixel | New to Emulation or Amiga scene | 10 | 14 March 2002 18:35 |
|
|