![]() |
![]() |
#21 |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Hi a/b,
Many thanks for yet another extremely helpful and useful post. Regarding the *ptr=((char)((STRPTR*)clparams[0])[i][0]); line. I was trying to get the pointer to point *at* the 1st character. I thought if I could I could then run through the string simply incrementing the pointer till I hit a /0. However as you have pointed out I stuffed up badly when I tried to find the length of it using strlen since I'd just got the 1st char and not a pointer to it. Think I understand what I've just typed... Thank you for the info regarding casting and the code snippet I've copied it into my library as I'm sure it'll be useful later on. Luckily I don't have to do any of this as my version of gcc includes a non ANSI strcasecmp (as well as strncasecmp) so thanks for pointing out their existence - my C book makes no mention of them. Could you suggest a good current one? Oh I'm using messages in the code so the user can localise the template if they wish - messages is defined as - Code:
static char *messages[]={MSG_READWRITE,MSG_NODISK,MSG_BADDISK,MSG_KICKSTART,MSG_NOT_DOS,MSG_READONLY,MSG_VALIDATING,\ MSG_MOUNTED,MSG_VOL_HEAD,"Unit","DOS","Size","Used","Free","Full","Errors","Status","Name","Amiga Disk","PC Disk",MSG_ERROR_MEM,MSG_BREAK,\ MSG_ERROR_LIB,TEMPLATE}; Once again massive thanks for all the help. ![]() |
![]() |
![]() |
#22 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
I can't remember ever seeing any localised command line arguments.
|
![]() |
![]() |
#23 | |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Quote:
I guess that Commodore must have hard coded everything then? Even after they introduced the localisation system in whatever os version it was. So much of the old OS info has been replaced by OS 4 specific stuff on the net its very hard to find the info you need. Anyway my app does offer this and provided it works and I can nail a stupid crash I'm fairly near finishing thanks to all the help I have had from folks on this forum. |
|
![]() |
![]() |
#24 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
Indeed Workbench uses localised default names for formatted disks.
|
![]() |
![]() |
#25 |
Amigan
![]() Join Date: Feb 2012
Location: London
Posts: 1,317
|
|
![]() |
![]() |
#26 | |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Quote:
To be honest I hadn't even thought about scripts! However I've fixed it by simply adding the switch; script. If this is included in the command line then the app uses the the default English arguments no-matter what the user has set the local command line to be. Obviously if they change the name of the app itself then there is little I can do about it. ![]() Thanks for pointing the possible issue out. |
|
![]() |
![]() |
#27 |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Oh well so much for *that* idea.
![]() Having added SCRIPT/S to my template I am now getting a software failure when the app exits of #80000004. Its not a Guru, but one of the suspend/Reboot type. The bizarre thing is that all the other switches work fine and the app exits correctly whether you enter anything on the command line or not. It only crashes if you enter SCRIPT. Here's the template. #define TEMPLATE "DEVICE/M,HELP/S,WINDOW/S,NOCOLOURS/S,COLOURS/S,LEADINGSPACE/S,TRAILINGSPACE/S,NORMALRAM/S,DECIMALSIZE/S,SCRIPT/S,DUD/S" I added the DUD switch just in case it was something odd with SCRIPT being the last switch. Adding DUD to the command line also causes the same error! Here's the code that reads the options. Initially I wasn't doing anything with the switches but then added the if checks with the zz=0; in them in pure desperation. Code:
/*get args if any from command line*/ Args=ReadArgs(TEMPLATE,clparams,NULL); /*check first on the default template for script switch*/ if (Args) /*entered something*/ { printf("entered args- clparams[0]=%d \n",clparams[0]); if (clparams[0]!= NULL) { printf("entered device\n"); i=0; while (((STRPTR*)clparams[0])[i]!=NULL) { printf("%s\n",((STRPTR*)clparams[0])[i]); i++; } } printf("OPTIONS STARTS AS %d\n",options); /* if ((clparams[3]==-1) && (clparams[4]==-1)) DO SOMETHING! <<<<<< cant have colours and no colours speced!*/ if ((clparams[3]==-1) && ((options & NO_COLOURS) ==0)) options=options | NO_COLOURS; /*if nocolours on cmd line and not in prefs file set*/ if ((clparams[4]==-1) && ((options & NO_COLOURS)> 0)) options=options - NO_COLOURS; /*if colours on cmd line and nocolours in prefs file reset */ if ((clparams[5]==-1) && ((options & LEADING_SPACES) == 0)) options=options | LEADING_SPACES; /*if want leading spaces and not in prefs file set*/ if ((clparams[6]==-1) && ((options & TRAILING_SPACES) == 0)) options=options | TRAILING_SPACES; /*if want trail scs and not in prefs fileset*/ if ((clparams[7]==-1) && ((options & NORMAL_RAM) == 0)) options=options | NORMAL_RAM; /*if want ram disk always 100% and not in prefs set*/ if ((clparams[8]==-1) && ((options & DEC_VALUES) == 0)) options=options | DEC_VALUES; /*if want fake values for sizes and not in prefs set */ if ((clparams[9]==-1)) { zz=0; /*test SCRIPT switch */ } if ((clparams[10]==-1)) { zz=0; /*test for odd crash */ } } printf("OPTIONS ENDS AS %d\n",options); The error occurs right at the very end of the main function at the line I have marked <<<<<<<<< : Code:
/*clear any stored volist*/ printf("Clearing vollist_head\n"); while(vollist_head) { vollist_temp=vollist_head->next; printf("vollist_temp mem is now %d\n",&vollist_temp); printf("About to freevec vollist_head %d\n",&vollist_head); FreeVec(vollist_head); vollist_head=vollist_temp; printf("OK\n"); } printf("FREE ARGS\n"); FreeArgs(Args); /* clear mem used for command line*/ printf("FREE INFODAT\n"); FreeVec(infodat); return_code=RETURN_OK; } printf("close lib UBase\n"); CloseLibrary(UBase); printf("close lib DBase\n"); CloseLibrary((struct Library *)DBase); printf("OK\n"); } else { if (DBase) { CloseLibrary((struct Library *) DBase); } Printf("%s\n",(long)messages[22]); } if (PrefsFile) /*if we allocated a prefs file free it*/ { printf("close PREFS file\n"); printf("free prefs =%x\n",PrefsFile); free (PrefsFile); printf("OK\n"); } } printf("END\n"); return return_code; /*<<<<<<<<<<<<CRASH!<<<<<<<<<<*/ } Why does it work fine with multiple devices specified, no devices specified, all the other switches no other switches etc etc. It just crashes if I specify SCRIPT or DUD! ![]() Is there a limit to the number of switches you can use? This is driving me nuts. |
![]() |
![]() |
#28 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,068
|
How is clparams defined, as [9] or [11]?
This looks like [9] and local (on stack) resulting in stack corruption. |
![]() |
![]() |
#29 | |
Registered User
Join Date: Dec 2016
Location: london
Posts: 178
|
Quote:
It's 9 - why I did't even think of checking this is beyond me Many thanks for saving my sanity once again a/b. (Wish there was a way of upvoting or something on this forum). |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ReadArgs implementation for kickstart 1.3 | jotd | Coders. Asm / Hardware | 19 | 06 February 2023 12:45 |
multiple use of traps | Galahad/FLT | Coders. General | 2 | 27 November 2014 10:53 |
Using ReadArgs() from asm | oRBIT | Coders. General | 4 | 11 May 2010 16:11 |
multiple HDFs | BippyM | request.UAE Wishlist | 1 | 24 September 2005 23:12 |
Multiple Harddrives | Unknown_K | support.Hardware | 3 | 25 March 2005 12:28 |
|
|