What is the data type of characters ie. "!", "+" in FreeBASIC? - char

I tried char and vargchar, but none of them work. i want to build a calculator and want to ask the user what symbol they want to use like +,-
i tried doing char and vargchar, but none of them work.
using fbide

Related

Prolog writeln with variables

I need to use writeln specifically in Prolog with a variable in it. What I am trying to make is an error that takes the first element of a list, and format does what I need almost perfectly, but again it specifically needs to be writeln.
I experimented for awhile and tried using '+' to concatenate the string like how it works in other languages, and when I use this
writeln("ERROR: \"" + Head + "\" is invalid.")
I almost succeed in what I want, and it prints
ERROR: " + a + " is invalid.
with the variable 'a' highlighted (another requirement) when I am trying to get
ERROR: "a" is invalid.
But I am unable to print it without using characters such as +, -, or | to contain the variable. I don't really understand what is going on and I haven't been able to find a reason on my own.
Using string_concat twice makes the proper string, but the variable is not highlighted like it is supposed to be.
As you already mentioned, using string_concat solves your problem as you want. String concatenation does not work like this in Prolog as it does in different languages. The reason why it still prints something when using the + while it throws without it is that the + is in an infix operator and is displayed as such in when using writeln because it also writes out the predicate names.
It will write the + infix when provided as prefix such as in this example:
writeln(+(3,2)).
It does not work without the + because then you simply have three different values after another. Quoted Atom, Variable filled with an Atom, Quoted Atom. Prolog expects a term though, so you run into a syntax error.

Should arguments to a custom directive be escaped?

I have created a custom directive for a documentation project of mine which is built using Sphinx and reStructuredText. The directive is used like this:
.. xpath-try:: //xpath[#expression="here"]
This will render the XPath expression as a simple code block, but with the addition of a link that the user can click to execute the expression against a sample XML document and view the matches (example link, example rendered page).
My directive specifies that it does not have content, takes one mandatory argument (the xpath expression) and recognises a couple of options:
class XPathTryDirective(Directive):
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {
'filename': directives.unchanged,
'ns_args': directives.unchanged,
}
def run(self):
xpath_expr = self.arguments[0]
node = xpath_try(xpath_expr, xpath_expr)
...
return [node]
Everything seems to be working exactly as intended except that if the XPath expression contains a * then the syntax highlighting in my editor (gVim) gets really messed up. If I escape the * with a backslash, then that makes my editor happy, but the backslash comes through in the output.
My questions are:
Are special characters in an argument to a directive supposed to be escaped?
If so, does the directive API provide a way to get the unescaped version?
Or is it working fine and the only problem is my editor is failing to highlight things correctly?
It may seem like a minor concern but as I'm a novice at rst, I find the highlighting to be very helpful.
Are special characters in an argument to a directive supposed to be escaped?
No, I think that there is no additional processing performed on arguments of rst directives. Which matches your observation: whatever you specify as an argument of the directive, you are able to get directly via self.arguments[0].
Or is it working fine and the only problem is my editor is failing to highlight things correctly?
Yes, this seems to be the case. Character * is used for emphasis/italics in rst and it gets more attention during syntax highlighting for some reason.
This means that the solution here would be to tweak or fix vim syntax file for restructuredtext.

Read string with caret symbol from windows console

I'm working on my own parser for mathematical functions as sin(x^2) in ANSI C. I've done really good code, but I need to read expression from console (cmd) and in argv[1], where should be whole expression is expression like x2 instead of x^2. Is there a way, how to compel console to read whole string with caret ^ symbol as a parameter?
I've tried to search something on google and here, but nothing useful.

Extended charsets chars not reccognized and converting to ? mark

I have a string contain some special char like "\u2012" i.e. FIGURE DASH. When i am trying to print this on console I am getting a '?' mark instead of its symbol. I have an editor where in I can insert the symbol using alt+numpad like alt+2012. In editor it I could see the symbol save it in a xml file and get the value using nodevalue, I get a '?' mark.
To summerize I am facing problem to read extended latin a charset. What i need is When i insert such symbols and read it, i should get something like &#xXXXX;.
Please help!
TIA :)
Simply I have a String inpath = "À";, I want to get its unicode value..like &#xXXXX;
The default console encoding in Windows is some MS-DOS code page and they don't support the character. You can try running chcp 65001 before running the program but you might also need to change the console font as well.
You don't need to do anything you wouldn't do with any other character, as long as you use UTF-8. You aren't doing that in many places. You need to explicitly write in your code to save and read the file in UTF-8, and not rely on the platform default encoding.

Need a better way to valid Computer name using C++ code

I am not trying to set the local hostname. In my app using a edit control need to accept a host name (fully qualified with DNS / without).
We do know we cannot use chars a (\ / ! # # $ % ^). Is there a better way than programmatically parsing the user input.
Code needs to work in all languages (multi byte char set)
Thanks
AnilG
Not that I could think of. The effort to do this yourself is pretty slim, though. See _mbschr and _mbscspn for good examples on how to search for a single character and multiple characters.
There is also a good overview over string functions supported by Visual Studio here.
char string[] = "xyzabc";
int pos;
pos = strcspn( string, "abc" );
printf( "First a, b or c in %s is at character %d\n", string, pos );
You can use the PCRE library to match the string against a regular expression.

Resources