Improper Output from call to subroutine

My program is meant to take input of GPA, student status, and credit hours from an excel worksheet and use them to calculate tuition, fees, discount, and total amount due for a given student.

I have to use separate subroutines to solve the tuition, fees, discount, and total for each person in the worksheet.

My problem is when I try to call a different subroutine to my primary subroutine and get a value I need, it displays a random number and doesn’t use access any part of the fees or other subroutines set values.

I’ve tried moving my declarations, but the code just gets more errors.

‘Primary subroutine Sub Proj_5p2()

‘Variables Dim dblGPA As Double Dim strStat As String Dim intRow As Integer Dim intCredHrs As Integer Dim curTuition As Currency Dim curFees As Currency Dim curDisc As Currency Dim curTotal As Currency

‘Processing Do While (Range(“a” & intRow) <> “”) ‘Get required input for each row dblGPA = Range(“c” & intRow).Value strStat = UCase(Range(“d” & intRow).Value) intCredHrs = Range(“e” & intRow).Value

'Call subroutines Call Tuition(curTuition, intCredHrs, strStat)  'Display subroutines Range("f" & intRow) = curTuition 

Loop

End sub

‘Call from subroutine Sub Tuition(curTuition As Currency, intCredHrs As Integer, strStat As String)

If strStat = "GRADUATE" Then     If intCredHrs < 18 Then         curTuition = 335 * intCredHrs     Else         curTuition = 6500 End If  ElseIf strStat = "UNDERGRADUATE" Then     curTuition = 550 * intCredHrs End If 

End Sub

I need it to calculate a students tuition based off their credit hours and status in college.

In my code, I had it do an undergrad with 10 credit hours. This should result in a Tuition of $ 3,350.00 but instead it just turns out a value of $ 300.00.

I have no idea where it gets the 300 from.

Different String output when converting csv file to tab-delimited text file in excel

In my CSV file, there are many text records without any " character at the beginning or at the end of each record. but when I convert CSV file to tab-delimited text file in excel, I got a file that some of its records begin and ends with " character. Also when I open my CSV file with another file reader like Notepad++, these characters also exist. So, please explain why this difference occurs and how can I prevent this? (How can I have same file outputs in both CSV and text format after conversion?)

How do I stop unwanted randomization of GarageBand software instrument output?

Obligatory version information: GarageBand 10.0.2 on Mac OS version 10.9.5.

Various software instruments in GarageBand projects tend to become unstable for unknown reasons. When this happens, they produce subtle random differences (such as random varying timbre, echo characteristics, and even tone) each time the project is exported.

Rigorously defined, this means that if you export the same project file twice into output files A and B, then A != B with extremely good probability. This behavior happens no matter what output format I use (tested with 128kbps MP3, 196kbps MP3, AAC, and AIFF).

I know some of the software instruments and configurations are random by nature. The unwanted randomization I’m seeing is happening with instruments that shouldn’t be random.

In case anyone’s asking why I’m using an old version of GarageBand, I recall a bad update where a bunch of useful features were removed.

Unexpected output from the merging of a quadtree, when that data is converted to Box2D fixtures

I’ve been staring at this code trying to troubleshoot this for the past 3 days, but I seem to have gone Code Blind. I KNOW the issue is stupidly simple, but I just can’t crack the problem.

I’m using a bastardized quadtree to store the terrain for a map. Each node is either full of children, or stores an instance of a tile (position data is saved in the tile). tile stores its AABB (x,y,w,h), and block type (1 = ground, 0 = air/nothing). Later it will store objects and entities as well. Inserting (right now) does NOT cause merging – that is a separate function call.

The darn thing renders properly if drawn to a Pixmap. Which drives me absolutely crazy.

Expected Output (image generated to PixMap from data) :

Expected output from a properly merged quadtree

Output WITHOUT merging (tile width/heigh is 8 pixels), totally as expected :

Perfectly normal representation of the above quadtree, without merging of same blocks (all data 8x8 pixel squares)

Output WITH merging (bizzare.) : The same exact quadtree in all other images, except the squares are not aligned at all.

Code which I am fairly sure is the problem (from the tile class) PPM is a constant defined elsewhere (Pixels Per Meter), set to 8. This is all rendered through LibGDX :

    public void setPhys(World w) {     if(this.block != 0) {         this.bdef = new BodyDef();         NovaLog.debug("bdef.position.set(" + (this.aabb.x / PPM) + ", " + (this.aabb.y / PPM) + ");");         bdef.position.set(this.aabb.x / PPM,this.aabb.y / PPM);         bdef.type = BodyType.StaticBody;         this.body = w.createBody(bdef);          PolygonShape shape = new PolygonShape();         NovaLog.debug("shape.setAsBox("+((this.aabb.width / PPM)/2) + ", " +  ((this.aabb.height / PPM)/2) +");");         shape.setAsBox((this.aabb.width / PPM)/2, (this.aabb.height / PPM)/2);         this.fdef = new FixtureDef();         this.fdef.shape = shape;         this.fixture = this.body.createFixture(fdef);         this.fixture.setUserData(this);     } } 

At this point, I’m a Westworld Host looking at something that could do harm to his psyche – “It doesn’t look like anything to me.” Please help – the bruise on my forehead from banging my head against the wall is growing larger.

How to flush the output, while WP still creates the page?

I develope a plugin, which takes several seconds do apply changes while saving data. While this time, the browser tries to open the options.php page.

How can I output some text there, before the changes are ready and WordPress forwards me back to the plugin settings page?

In PHP there is a function “flush”, but it doesn’t work. The script will be terminated, but there is no further redirect to the settings page.

Matplotlib output messed up in Kubuntu 18

I run the same Python3 code on several computers for plotting data. On one of them, I have got Ubuntu 16.04, the others are Kubuntu 18.04 and 18.10. In Kubuntu, the plot is completely messed up, the one that I get in Ubuntu is definitely the right one.

The characteristics of the mess also differs from time to time and from computer to computer. So these points sometimes follow a horizontal trend, sometimes it is completely messed up, but I could not find any systematic difference in the environment.

The physical size of the plot in Kubuntu is also smaller than it should be.

I have encountered the same issue for the plot of some (but not all) of my other programs as well. So for some code, it is the same as what I get from the Ubuntu machine, sometimes it is like the picture below.

I installed matplotlib via pip3 and tkinter in the same manner on all computers, therefore I guess that the only difference is the distribution and version. I also tried to run it in Python2, but the output is the same. (Although there may be other aspects that I do not consider.)

The top image is from Kubuntu, the bottom is from Ubuntu for the same dataset.

The output from Kubuntu

enter image description here

Have you got any idea what can go wrong?

Why can’t we generate the output of a cellular automata at time step t without first generating all the preceding states

Why can’t we generate the output of cellular automata at time step t without first generating all the preceding states? Why can we do this for some functions? What features of a function does it relate to? Is it about whether it can be graphed as a line or a curve? Why can’t we come up with a function that takes in a cellular automata ruleset and a timestep t and gives us the output in constant time with respect to t?

Override digital-out audio output Mac

I broke the headphone jack of my MacBook, so now you only hear the right-side, even with mono-audio on. But when I unplug the headpones, the speakers are turned off and only Digital-Out can be seen in the sound settings.

But the weirdest thing is in Ubuntu or any other OS the speakers work, headphone still only one side, but it worls. But on Mac OS even a other Hard Drive it does not work. Only the startup chime works. For the record there is no red light in the headphone jack. Probably physical damage inside the jack.

Any way I can make the speakers also work in MacOS again ? Thanks!

Kind regards,

Aaron

A small PHP library for styling terminal output

I’ve attempted to make a small PHP library for styling terminal output using ANSI escape sequences. The repo is located here

To be honest, I am not really satisfied with the current structure of my code. It seems to be “not good”. But I don’t know any better ways to structure it.

Please feel free to make any critics! I really appreciate it.

Thank you!

Chalk.php

<?php namespace TdTrung\Chalk; use TdTrung\OSRecognizer\OSRecognizer; class Chalk {     const RESET = "3[0m";     private $  styles = [         'reset' => 0,         'bold' => 1,         'dim' => 2,         'italic' => 3,         'underscore' => 4,         'blink' => 5,         'inverse' => 7,         'strikethrough' => 9,         'black' => 30,         'red' => 31,         'green' => 32,         'yellow' => 33,         'blue' => 34,         'magenta' => 35,         'cyan' => 36,         'lightGray' => 37,         'darkGray' => 90,         'lightRed' => 91,         'lightGreen' => 92,         'lightYellow' => 93,         'lightBlue' => 94,         'lightMagenta' => 95,         'lightCyan' => 96,         'white' => 97     ];     private $  twoStageFns = ["rgb"];     private $  osRecognizer;     private $  supportLevel = 0;     private $  enableColor = true;     public function __construct()     {         $  this->initSeqBuilders();         $  this->osRecognizer = new OSRecognizer;         $  this->checkColorSupport();     }     private function initSeqBuilders()     {         foreach ($  this->styles as $  name => $  code) {             $  this->styles[$  name] = function ($  offset) use ($  code) {                 if ($  code > 0)                     $  code = $  offset + $  code;                 return "3[{$  code}m";             };         }         $  this->styles["rgb"] = function ($  r, $  g, $  b, $  offset) {             // TODO: Fallback to ANSI 256 if possible             if (!$  this->has16mSupport()) return "";             $  type = 38 + $  offset;             return "3[{$  type};2;{$  r};{$  g};{$  b}m";         };     }     private function checkColorSupport()     {         if (getenv('TERM') === 'dumb') {             return 0;         } else if (strpos($  this->osRecognizer->getPlatform(), 'win') !== false) {             // get os version and build             $  release = explode('.', $  this->osRecognizer->getRelease());             if (intval($  release[0]) >= 10 && intval($  release[1]) >= 10586) {                 $  this->supportLevel = intval($  release[2]) >= 14931 ? 3 : 2;                 return;             }             $  this->supportLevel = 1;         } else if (strpos(getenv('COLORTERM'), 'truecolor') !== false) {             $  this->supportLevel = 3;         } else if (function_exists('posix_isatty') && @!posix_isatty(STDOUT)) {             $  this->supportLevel = 1;         } else if (preg_match('/-256(color)?$  /i', getenv('TERM'))) {             $  this->supportLevel = 2;         } else if (preg_match('/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i', getenv('TERM'))) {             $  this->supportLevel = 1;         } else {             $  this->supportLevel = 0;         }     }     private function is256Color($  styleName)     {         return preg_match('/^color\d+/i', $  styleName);     }     private function isValidStyle($  styleName)     {         if (!(strpos($  styleName, 'bg') === false)) {             preg_match('/^bg(\w+)$  /', $  styleName, $  match);             $  styleName = lcfirst($  match[1]);         }         return array_key_exists($  styleName, $  this->styles) || $  this->is256Color($  styleName);     }     private function parseStyleName($  styleName)     {         $  offset = 0;         if (!(strpos($  styleName, 'bg') === false)) {             $  offset = 10;             preg_match('/^bg(\w+)$  /', $  styleName, $  match);             $  styleName = lcfirst($  match[1]);         }         return [$  offset, $  styleName];     }     private function get256Sequence($  styleName, $  offset)     {         preg_match('/^color(\d+)/i', $  styleName, $  match);         $  offset += 38;         return "3[{$  offset};5;{$  match[1]}m";     }     public function isTwoStageFns($  styleName)     {         return array_search($  styleName, $  this->twoStageFns) !== false;     }     public function disableColor()     {         $  this->enableColor = false;     }     public function hasColorSupport()     {         return $  this->supportLevel >= 1;     }     public function has256Support()     {         return $  this->supportLevel >= 2;     }     public function has16mSupport()     {         return $  this->supportLevel >= 3;     }     public function __get($  styleName)     {         if (!$  this->isValidStyle($  styleName)) {             throw new InvalidStyleException($  styleName);         }         list($  offset, $  styleName) = $  this->parseStyleName($  styleName);         if ($  this->is256Color($  styleName)) {             $  style = $  this->get256Sequence($  styleName, $  offset);         } else {             $  style = $  this->styles[$  styleName]($  offset);         }         return new StyleChain($  style, $  this);     }     public function __call($  styleName, $  arguments)     {         if (!$  this->isValidStyle($  styleName)) {             throw InvalidStyleException($  styleName);         }         list($  offset, $  styleName) = $  this->parseStyleName($  styleName);         if ($  this->isTwoStageFns($  styleName)) {             array_push($  arguments, $  offset);             return new StyleChain(                 call_user_func_array($  this->styles[$  styleName], $  arguments),                 $  this             );         } else if ($  this->is256Color($  styleName)) {             $  style = $  this->get256Sequence($  styleName, $  offset);         } else {             $  style = $  this->styles[$  styleName]($  offset);         }         array_unshift($  arguments, [$  style]);         return call_user_func_array([$  this, 'apply'], $  arguments);     }     public function apply()     {         if (func_num_args() < 2) throw new InvalidArgumentException('Insufficient arguments (at least 2 are required)');         $  styles = func_get_arg(0);         $  strings = func_get_args();         array_shift($  strings);         $  text = implode(" ", $  strings);         if (!$  this->enableColor || !$  this->hasColorSupport()) return $  text;         return array_reduce($  styles, function ($  carry, $  style) {             return "{$  style}{$  carry}" . Chalk::RESET;         }, $  text);     } } 

StyleChain.php

<?php /**  * Exception TdTrung\Chalk  *  * @package TdTrung\Chalk  * @author  Tran Dinh Trung <trandinhtrung176@gmail.com>  */ namespace TdTrung\Chalk; class StyleChain {     public $  styles = [];     private $  colorInstance;     public function __construct($  style, Chalk $  colorInstance)     {         array_push($  this->styles, $  style);         $  this->colorInstance = $  colorInstance;     }     public function __invoke()     {         $  arguments = func_get_args();         array_unshift($  arguments, $  this->styles);         return call_user_func_array(             [$  this->colorInstance, 'apply'],             $  arguments         );     }     public function __get($  prop)     {         $  other = $  this->colorInstance->{$  prop};         $  this->merge($  other);         return $  this;     }     public function __call($  method, $  arguments)     {         if ($  this->colorInstance->isTwoStageFns($  method)) {             $  result = call_user_func_array(                 [$  this->colorInstance, $  method],                 $  arguments             );             $  this->merge($  result);             return $  this;         }         $  other = $  this->colorInstance->{$  method};         $  this->merge($  other);         return call_user_func_array([$  this, '__invoke'], $  arguments);     }     private function merge(StyleChain $  other)     {         $  this->styles = array_merge($  this->styles, $  other->styles);     } }