Sponsored Content
The Lounge What is on Your Mind? Coding Style at UNIX.com forums Post 303029242 by wisecracker on Wednesday 23rd of January 2019 03:36:41 PM
Old 01-23-2019
Hi stomp...
(Apologies for typos, etc...)

Well I don't code for a living and apart from my 'mis-use' of the shell and the terminal I do stuff that is often frowned upon by some professionals.

1) I code to work, NOT work to code. This can result in naive coding in places.
2) I use lots of comments. Take a look at my Post #13 here: One liners, quick rant...
3) I use globals a lot and understand perfectly that even functions can see them.
4) I use throw away variables that can be used anywhere and initialise them on every use; Audioscope.sh for example I have 2 for numbers and 2 for strings:
Code:
# "count", "number", "char" and "str" are reusable, throw away variables.
count=0
number=0
char='$VER: AudioScope.sh_(C)2013-2019_B.Walker_G0LCU_Released_Under_CC0_Licence.'
str='$VER: AF_Spec_An.sh_(C)2017-2019_B.Walker_G0LCU_Released_Under_CC0_Licence.'

YES, I am still working on AudioScope.sh so there will be another upload soon.

5) I structure my programming and love seeing it from you guys, the best thing about Python although I have all but abandoned it now.
6) I use variable names that apply to the code or function written, see number 4) above.
7) I am an advocate of the JMP/GOTO low and high level _instructions_ in assembler, C, right up to BASIC if need be, see Post #9 here: Embed text in C code
Here is a much more rigid version that works from Apple's current 'gcc' version to the absolute current 'gcc' version.
Code:
/* hidden_text.c */
/* Guaranteed to allow up to 120 hidden ASCII characters using gcc. */

#include <stdio.h>

int main(void)
{
	/* The '(C)' string is hidden inside this assembler code. */
	/* Choose from .att_syntax or .intel_syntax. */
	asm("	.intel_syntax;"
	"	jmp getout;"
	"useless:"
	"	.asciz \"'$VER Hidden_Text_Version_1.00.00_(by_B.Walker)_CC0_Licence_[www.unix.com].'\\n\";"
	"getout:"
	"	nop;"
	);
	printf("\nThis should be in the data section.\n");
	printf("The hidden string is inside the code section.\n\n");
	return 0;
}

8) I do write in BASIC and I am a moderator, although not in much use now, for ACE BASIC Compiler for the AMIGA (C)David Benn.
I use the limited BWBasic a lot for the AMIGA and successfully got the USB Arduino Diecimila to talk to it using a home built RS232 adaptor.
9) As quoted at 1) I admit to being a naive coder often, because without the variety of machines that you professionals use then first principles apply to me.
10) I just LERVE getting languages to do things they were not designed to do. Hence some of my bizarre uploads to here.
11) And finally I consider myself a semi-pro' now rather than amateur, many thanks to you guys...
There may be others but at this point I can't remember them but my one phrase is: "if there is a back door then I will find it"; hence my mis-use of the shells and terminal.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix Coding Standards

Hi, I am looking for some coding standards for Unix Shell Scripting. Can anyone help me out in this? Regards, Himanshu (3 Replies)
Discussion started by: himanshu_s
3 Replies

2. UNIX for Dummies Questions & Answers

Unix coding tip required

Hi! Suppose I am at a location xyz:/abc1/abc2/abc3 Is it possible to move to another location xyz:/mnl1/mnl2/mnl3 by some coding within a script? (5 Replies)
Discussion started by: udiptya
5 Replies

3. Shell Programming and Scripting

[Unix] a dos style rename wont work

Hey guys i'm creating a dos style rename script, so if a user types say q14.* as the 1st param and b14.* as the 2nd and will rename all q14 files to b14 but keep the extensions, so i've developed nearly the full script "i think", if i use echo(echo "if $1 had been renamed it would now be... (3 Replies)
Discussion started by: fblade1987
3 Replies

4. Solaris

Getting Started in UNIX - incorporating C coding

I'm just starting a 'serious' coding in UNIX, so what I need is to run a C code on UNIX, What do I have to install (app) prior to coding/running the code and how do I compile that code? can I write my c code in UNIX or I need to have a visual studio for this? (7 Replies)
Discussion started by: Peevish
7 Replies

5. UNIX for Dummies Questions & Answers

Unix coding for triggering informatica

Hi, I have very little knowledge with unix and pmcmd. I need help with a issue. I have to see whether a file has been dropped in a particular location/path. If the file dropped I have to check the last modified time, which should be greater than 8pmEST the prior day. If the file has been... (4 Replies)
Discussion started by: redwolves
4 Replies

6. What is on Your Mind?

Filenames with hyphens - UNIX style?

Hello everyone! Filenames with hyphens instead of everything else that can be as a space - is it particularly UNIX style of naming or a general practice? It kinda is so in my mind that DOS guys use underscores as spaces and UNIX guys use dashes. Is it so? (5 Replies)
Discussion started by: guest115
5 Replies

7. Shell Programming and Scripting

UNIX script coding help?

Unix script coding help? i am trying to write a code that will display following menu to user: (A) Add (B) Subtract (C) Multiply (D) Divide (E) Modulus (F) Exponentiation (G) Exit Then ask user for choice (A-F). After taking users choice ask user for two numbers and perform... (3 Replies)
Discussion started by: renegade755
3 Replies

8. Homework & Coursework Questions

UNIX script coding HW question

i am trying to write a script code in unix that will: 1. The problem statement, all variables and given/known data: display following menu to user: (A) Add (B) Subtract (C) Multiply (D) Divide (E) Modulus (F) Exponentiation (G) Exit Then ask user for choice (A-F). After taking... (5 Replies)
Discussion started by: renegade755
5 Replies

9. Programming

Coding Style checking

Is there any opensource tool which can check the coding style use in C/C++ program. (3 Replies)
Discussion started by: zinat
3 Replies
ppd_emit_to_file(3)					     Library Functions Manual					       ppd_emit_to_file(3)

NAME
ppd_emit_to_file, ppd_emit_to_fd - Output device specific code. SYNOPSIS
#include <ppd/ppd.h> gboolean ppd_emit( PpdFile * ppd,FILE *fp,PpdSectionOrder section ); gboolean ppd_emitfd( PpdFile * ppd, int fd,PpdSectionOrder section ); DESCRIPTION
The ppd_emit_* functions output the device specific code appropriate to the specified section that has not already been emitted.. The PpdFile pointer is obtained from opening a PPD file via the ppd_load(3) family of functions. The section can be any one of the following: PPD_ORDER_ANY Option code can be anywhere in the file PPD_ORDER_DOCUMENT Option code must be in the DocumentSetup section PPD_ORDER_EXIT Option code must be sent prior to the document PPD_ORDER_JCL Option code must be sent as a JCL command PPD_ORDER_PAGE Option code must be in the PageSetup section PPD_ORDER_PROLOG Option code must be in the Prolog section The sections PPD_ORDER_DOCUMENT and PPD_ORDER_PAGE will also output code from the PPD_ORDER_ANY section. Once a code section has been emitted it is marked as such and will not be emitted unless it is re-marked. EXAMPLE
/* Setup code to emitted */ ppd_mark_defaults(ppd); ppd_mark_option(ppd,"Duplex","DuplexNoTumble"); ppd_mark_option(ppd,"PageSize","A4"); /* Emit initial code (including any reset and JCL code) */ ppd_emit_to_file(ppd,stdout,PPD_ORDER_EXIT); fputs(ppd->jcl_begin->str,stdout); ppd_emit_to_file(ppd, stdout, PPD_ORDER_JCL); fputs(ppd->jcl_ps->str, stdout); /* Any header comments go here */ ... /* Prolog section */ printf("%%%%BeginProlog0); ppd_emit_to_file(ppd, stdout, PPD_ORDER_PROLOG); printf("%%%%EndProlog0); /* Setup section */ printf("%%%%BeginSetup0); ppd_emit_to_file(ppd, stdout, PPD_ORDER_DOCUMENT); printf("%%%%EndSetup0); /* Main document begins */ for (...) { printf("%%%%Page: 1 10); /* Re-mark so that this is emitted on each page */ ppd_mark_option(ppd,"PageSize","A4"); printf("%%%%PageSetup0); ppd_emit_to_file(ppd, stdout, PPD_ORDER_PAGE); printf("%%%%EndPageSetup0); /* Page info goes here */ ... } /* Send ending JCL code */ fputs(ppd->jcl_end->str,stdout); SEE ALSO
ppd_file_new(3), ppd_file_free(3) ppd_emit_to_file(3)
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy