Posturl() result assigned to an integer field


I have a procedure that uses posturl() in Panorama X to get the next numeric value from a Panorama Enterprise shared database. The Enterprise server is set to return text (cgiContentType=“text/plain”). The posturl() result is put in a variable called vcgiResults. Everything works great except when I am trying to assign the value in the variable vcgiResults to an integer field in Panorama X called mRecordID. Here is the code.

mRecordID=int(val(vcgiResults)). It will work if I assign the contents of vcgiResults to a text field but not a number field with the integer type.


I made a little test with a new database with a text field “TextResult” and an integer field “ResultAsInteger”. I put a decimal number in a variable and assigned it to both fields. It worked as expected, even when I omitted the int( function. Here is my code (in German number format – the comma is the decimal separator):

local vText
vText = "3,14"
TextResult = vText
ResultAsInteger = val(vText)


I just followed your example and added “.00” to the vcgiResults variable and it worked. So, for example, the text value “80” will not work and the value that appears in my field mRecordID is 0, but the text value “80.00” will and the value that appears in my field mRecordID is 80. Im not sure why I needed to add the decimals.

But thank you.

Steve, I repeated my little test with the String “80” in the variable. No problem, it worked without any issue.

So I am thinking that your posturl() function is exporting some kind of invisible character. Maybe you should make sure that you get number characters only. (Text funnels)

You never said what the result was with this assignment. Was there an error? The wrong value (zero perhaps)? Kurt may be on to something with his idea of an invisible character. I would use the radixstr( function to see if there is anything extra in there you weren’t expecting.

Hi Jim,

There was not an error but 0 was the result. Also, I have tried message radixstr(“octal”,vcgiResults) and it generates an error “radixstr( function error: value parameter must be a number.” not sure what I am doing wrong. I have never used radixstr()

For anything other than a number, radixstr(16, or radixstr(“hex”, is the only option. For this, you would want to use


or equivalently


Each pair of hex digits represents a byte, which in this case should also be a character. Numerals will be in the range 30 for zero to 39 for nine. A decimal point will be 2E.

Thank you Dave, I tried radixstr(“hex”,texttobinary(vcgiResults)) the result is 313030, Enterprise Server returned the text value of 100.

Each pair of hex digits represents a byte, which in this case should also be a character. Numerals will be in the range 30 for zero to 39 for nine. A decimal point will be 2E.

If I understand your explanation correctly, there are no mystery characters. 31=1, 30=0 and 30=0, 100. So I guess we are back to the question of the purpose of adding “.00” to the variable vcgiResults to get it to work correctly.

One more thought, when I was using the same posturl() procedure in a different database and passing the result from the variable, vcgiResults, as a parameter() using farcall to call a procedure that would then assign the mRecordID field the value of the parameter it would work without adding the “.00”.

You could also use the characterfilter( function along with the asc( function to check for character values.


In this case the numerals 0-9 would range between 48 & 57 while the decimal point would be 46.

I tried a couple of experiments. One was this procedure

Local vcgiResults
vcgiResults = "100"
mRecordID = vcgiResults

It put the number 100 in the mRecordID field, which was an integer field. The next procedure I tried was

Local vcgiResults
vcgiResults = texttobinary("100")
mRecordID = vcgiResults
A_Text_Field = vcgiResults

That put 0 in mRecordID and 100 in A_Text_Field, which you may have guessed was a text field. Changing that to

Local vcgiResults
vcgiResults = texttobinary("100")+".00"
mRecordID = vcgiResults
A_Text_Field = vcgiResults

put 100 in mRecordID and 100.00 in A_Text_Field. That is all consistent with the notion that vcgiResults actually contains binary data, rather than text. My only problem with that theory is that using textobinary( on data that is already binary datatype is an error, so


should have resulted in an error, if vcgiResults had a binary datatype. Just to be sure though, you might want to try

message datatype(vcgiResults)

and see what you get.

Hi Dave, message datatype(vcgiResults) resulted in “Text”.

Is it possible for Panorama 6 Enterprise to return binary data when the Enterprise server is set to return text (cgiContentType=“text/plain”)?

Everything on a computer is binary data. Datatype is a matter of how those ones and zeroes will be interpreted. When Panorama X does a fileload( for example, it calls it binary data, because files can contain all sorts of data. It gets interpreted as text, if you use a binarytotext( function to tell it to do that. The binary data datatype basically means that Panorama X doesn’t know how those ones and zeroes should be interpreted,

When you said you were using loadurl( it should have immediately occurred to me that the result might be binary data, not text. That is definitely what is going on here, but I was a bit slow on the uptake. Whether loadurl( returns text or binary data depends on the settings of the server. Apparently your server is returning binary data (the server can do that even though you’ve specified text/plain).

What’s undoubtably confusing the matter is that when text is the only type of data that makes sense, Panorama tries to be helpful and often will automatically convert binary to text for you (assuming UTF8 encoding). So when you appended +".00" to the value, Panorama helpfully converted it to text, and then the val( function worked. The val( function doesn’t automatically convert binary to text because text isn’t the only type of parameter that is allowed – it will also accept numbers (which it just passes thru unchanged).

Usually the only time you have to worry about binary data is when you are accessing external data – in particular with loadurl( and fileload(, plus other functions that access files and urls. If there is any doubt, you should explicitly convert the data you get from these function to text with the binarytotext( function.

So this little mystery is solved! The reason no one else was able to duplicate this is because they weren’t accessing data from your server.

You can probably get your server to return text instead of binary data by changing the Apache configuration. I’m not sure how to do that, and I wouldn’t do that if I were you. Probably better to just get in the habit of using the binarytotext( function.

Thank you Jim,

One quick question, The server is a mac mini running Panorama Enterprise Server with it set to return text (cgiContentType=“text/plain”). I am accessing a Panorama 6 database to get the value. Will this change anything in your explanation?

I understood all that, so no, it doesn’t change anything. The actual transfer of data over the network is being done by the Apache software on your server, not directly by Panorama.