Why can't I post a response without making it code? There is no code at all in a response I made and I cannot get it posted because I recieve the error:

If posting a code snippet, use the Code button in the editor toolbar

The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text.
Post: Markdown Syntax: Formatting Help

http://www.daniweb.com/software-development/cpp/threads/422081/phone-management-system#post1801434 is my post...

Recommended Answers

All 11 Replies

The problem was the {...} delimiters in the post. It looks like Dani added a code validation rule to account for weaknesses in the editor's highlighting algorithms, and it explicitly disallows braces for some reason. I'm not sure what the reason is, as we've disabled the only place in Markdown that I'm aware of where braces are meaningful.

I'll let Dani weigh in when she wakes up, but that's the reason. :)

This is a bug. I'll fix it shortly .:)

Member Avatar for loserspearl

Still having this error...

I went ahead and did make changes last month to what flags braces. Can you give me an example of what you're trying to post and what it's not letting you? Thanks!

Member Avatar for loserspearl

I was looking for advice on my C# code, I used the code inserter as daniweb started using. Restarted post twice making sure to not mess with the code insertion, including a lot of code with special characters like: { / " ( ; [ *

            //variable replacing operand
            public static string variabReplace(string probValue, string[] operandValStr)
            {
                int symbolValue = rand.Next(1, 4);
                //e for error
                string variabValue = "E";
                switch (symbolValue)
                {
                    case 1: variabValue = "x";
                        break;
                    case 2: variabValue = "y";
                        break;
                    case 3: variabValue = "z";
                        break;

                }
                //replaced a random operand with variable
                string variabReplaceKey = operandValStr[rand.Next(1, operandValStr.Length)];
                StringBuilder variabBuild = new StringBuilder(probValue);
                variabBuild.Replace(variabReplaceKey, variabValue);
                return variabBuild.ToString();
            }

Yet I can somehow include code here, but this is only 1 method. I've never had this error even on c# code I posted 2 weeks ago. You can view the exact code I was trying to post here.

Just tried it. Works for me? Tried as a reply as well as a new thread.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AcceleratedAptitude
{

    public class ProblemGenerator
    {
        static Random rand = new Random();

        //randomed operand value range
        public static Tuple<int, int> operandValueRangeGen(int difficultyRange)
        {
            Tuple<int, int> operandValueRange = new Tuple<int, int>(0, 0);
            //preliminary difficulty chooser
            switch (difficultyRange)
            {
                case 1: operandValueRange = new Tuple<int, int>(1, 21);
                    break;
                case 2: operandValueRange = new Tuple<int, int>(-20, 41);
                    break;
                case 3: operandValueRange = new Tuple<int, int>(-30, 61);
                    break;
                case 4: operandValueRange = new Tuple<int, int>(-50, 100);
                    break;
            }
            return operandValueRange;
        }

        //randomed amount of operand range
        public static Tuple<int, int> operandAmntRangeGen(int difficultyAmnt)
        { 
            Tuple<int, int> operandValueRange = new Tuple<int, int>(0, 0);
            //preliminary difficulty chooser
            switch (difficultyAmnt)
            {
                case 1: operandValueRange = new Tuple<int, int>(3, 6);
                    break;
                case 2: operandValueRange = new Tuple<int, int>(3, 8);
                    break;
                case 3: operandValueRange = new Tuple<int, int>(4, 9);
                    break;
                case 4: operandValueRange = new Tuple<int, int>(5, 13);
                    break;
            }
            return operandValueRange;
        }

        //pseudo random int operand generation
        public static int[] operandGenInt(Tuple<int, int> operandValueRange, Tuple<int, int> operandAmntRange)
        {
            //amount of operands
            int operandAmntNum = rand.Next(operandAmntRange.Item1, operandAmntRange.Item2);
            int threshCtr = 0;
            int threshold = operandValueRange.Item2 / 2;
            int[] operandValue = new int[operandAmntNum];

            for (int ctr = 0; ctr < operandAmntNum; ctr++)
            {
                operandValue[ctr] = rand.Next(operandValueRange.Item1, operandValueRange.Item2);
                //check and change threshold so not all the numbers are too high
                if (operandValue[ctr] > threshold)
                    threshCtr++;
                if (threshCtr > operandAmntNum / 2)
                    operandValue[ctr] = rand.Next(operandValueRange.Item1, threshold);
            }
            return operandValue;
        }

        //pseudo decimal operand generation
        public static double[] operandGenDec(Tuple<int, int> operandValueRange, Tuple<int, int> operandAmntRange)
        {
            //amount of operands
            int operandAmntNum = rand.Next(operandAmntRange.Item1, operandAmntRange.Item2);
            int threshCtr = 0;
            int threshold = operandValueRange.Item2 / 2;
            double[] operandValue = new double[operandAmntNum];

            for (int ctr = 0; ctr < operandAmntNum; ctr++)
            {
                operandValue[ctr] = rand.Next(operandValueRange.Item1, operandValueRange.Item2);
                //round to tenths
                operandValue[ctr] += Math.Round(rand.NextDouble(), 1);
                //check and change threshold so only half the numbers are greater than half the value
                if (operandValue[ctr] > threshold)
                    threshCtr++;
                if (threshCtr > operandAmntNum / 2)
                {
                    operandValue[ctr] = rand.Next(operandValueRange.Item1, threshold);
                    operandValue[ctr] += Math.Round(rand.NextDouble(), 1);
                }

            }
            return operandValue;
        }

        //operator generation
        public static char[] operatorGen(Tuple<int, int> operatorType, int operandAmnt)
        {
            //amount of operators 1 less than operands, but ends with '=' character
            int[] symbolValue = new int[operandAmnt - 1];
            //randomizing operators
            for (int ctr = 0; ctr < symbolValue.Length; ctr++)
            {
                //1 for addsub 2 for multdiv
                symbolValue[ctr] = rand.Next(operatorType.Item1, operatorType.Item2);
            }
            char[] symbolCompute = new char[operandAmnt];
            //converts random numbers in corresponding symbols for display and compute
            for (int ctr = 0; ctr < symbolValue.Length; ctr++)
            {
                switch (symbolValue[ctr])
                {
                    case 1: symbolCompute[ctr] = addSubGen();
                        break;
                    case 2: symbolCompute[ctr] = multDivGen();
                        break;
                }
            }
            symbolCompute[symbolValue.Length] = '=';
            return symbolCompute;
        }

        //additive
        public static char addSubGen()
        {
            int symbolVal;
            //e for error
            char operatorVal = 'E';
            symbolVal = rand.Next(1, 3);
            switch (symbolVal)
            {
                case 1: operatorVal = '+';
                    break;
                case 2: operatorVal = '-';
                    break;
            }

            return operatorVal;
        }

        //multiplicative
        public static char multDivGen()
        {
            int symbolVal;
            //e for error
            char operatorVal = 'E';
            symbolVal = rand.Next(1, 3);
            switch (symbolVal)
            {
                case 1: operatorVal = '*';
                    break;
                case 2: operatorVal = '/';
                    break;
            }

            return operatorVal;
        }

        //converts int to string array for string builder and variable replacement
        public static string[] intConvert(int[] operandValue)
        {
            string[] operandStr;
            operandStr = Array.ConvertAll<int, string>(operandValue, new Converter<int, string>(intToStr));

            return operandStr;
        }
        private static string intToStr(int operand)
        {
            return operand.ToString();
        }

        //converts decimal to string array for string builder and variable replacement
        public static string[] decConvert(double[] operandValue)
        {
            string[] operandStr;
            operandStr = Array.ConvertAll<double, string>(operandValue, new Converter<double, string>(decToStr));

            return operandStr;
        }
        private static string decToStr(double operand)
        {
            return operand.ToString();
        }

        //assemble operand strings (regardless of decimal or int) and operator char
        public static string mathAssembly(string[] operandValStr, char[] operatorVal)
        {
            string problemStr;
            StringBuilder mathBuild = new StringBuilder();
            //mathBuild.EnsureCapacity(operandValStr.Length + operatorVal.Length);
            int ctrStr = 0;
            do
            {
                mathBuild.Append(operandValStr[ctrStr]).Append(operatorVal[ctrStr]);
                ctrStr++;
            }
            while (ctrStr < (operandValStr.Length));
            return problemStr = mathBuild.ToString();
        }

        //variable replacing operand
        public static string variabReplace(string probValue, string[] operandValStr)
        {
            int symbolValue = rand.Next(1, 4);
            //e for error
            string variabValue = "E";
            switch (symbolValue)
            {
                case 1: variabValue = "x";
                    break;
                case 2: variabValue = "y";
                    break;
                case 3: variabValue = "z";
                    break;

            }
            //replaced a random operand with variable
            string variabReplaceKey = operandValStr[rand.Next(1, operandValStr.Length)];
            StringBuilder variabBuild = new StringBuilder(probValue);
            variabBuild.Replace(variabReplaceKey, variabValue);
            return variabBuild.ToString();
        }

        //exponent attachment to operand or paren
        public static string exponInsert(string probValue, string[] operandValStr)
        {
            //would replace multiples if random makes same number twice
            //value for exponent
            int exponValue = rand.Next(1, 5);
            //replace a random operand 
            int exponReplaceValue = rand.Next(1, operandValStr.Length);
            //create a new string including value and exponent
            string exponInsertStr = operandValStr[exponReplaceValue] + "^" + exponValue.ToString();
            string exponReplaceStr = operandValStr[exponReplaceValue];

            StringBuilder exponInsertBuild = new StringBuilder(probValue);
            exponInsertBuild.Replace(exponReplaceStr, exponInsertStr);
            return exponInsertBuild.ToString();
        }

        public static string fractAssembly(char[] operandValue, char[] operatorValue)
        {
            string problemStr = "";





            return problemStr;
        }
    }
}
Member Avatar for loserspearl

Not sure why, I've retried twice now, Win7 64bit Chrome. Ill try a different browser.

Member Avatar for loserspearl

Just tried IE 64-bit and still got the error.

And a copy of the exact text gave the same error when trying to do a reply here. I've restarted my computer and retried and the same thing for both broswers. Note: java isn't currently working on my PC, but I wouldnt think a web editor would be JVM dependant.

What error are you getting, exactly?

Member Avatar for loserspearl

"The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text."

There's something that you're doing that's different than what I'm doing. Nothing having to do with Javascript or your web browser would give you this error message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.