Jump to content

Welcome to me and a problem with decimal on iSeries


 Share

Go to solution Solved by llewxam,

Recommended Posts

Hi everybody :)

Nickname "Overhill" cover Mario Pippia, from Torino, Italy :)

I work on iSeries, in RPG, until 1986, so I am an old, old programmer. But I like all news in this world, and tanks to my friend Roy, I've found this amazing language.

Now I'm tryng to understand all its secret, expecially when connected to an iSeries (or AS/400, if you prefer :) )

Now I have a little problem with decimals: with an ODBC connection, my program read a file with the prices of my articles, and obviously that prices are in Euro, so with a variable number of decimals, but never less than two.

My problem is when I read the "value" proprierty of the Fields("PRMIL"), where the correct price is: the value is without decimals!

Of course they are extremely important!

...
        $sSql = "Select PRMAL, PRMEL, PRMIL from " & $dftDataLibrary & "." & $dftListFile & _
                " Where CDLSL = '" & $sCDLIS & "'" & _
                " and   CDARL = '" & $sCDPAR & "'" & _
                " and   QTSCL >=" & $sQTY
        $oListRecord.Open($sSQL, $oConnection)
        $oListRecord.MoveFirst

        msgbox(0, " ", $oListRecord.Fields.Item("PRMIL").Value)
        ...

This is the piece of code where I check the value, and the value is "4,20" on iSeries, but only "4" in the MsgBox :o

(in Italy we use a comma instead a point to separate decimal, you know :) )

What I have to do to have a correct field with all decimals at their places? :)

Thanks for you attention, and have a nice Halloween! :D

Bye

Mario "Overhill" Pippia

Link to comment
Share on other sites

  • Solution

Have you figured out your problem yet?  I assume you have a way other than AutoIt that you can check to make sure the answer come up properly, to make sure it is not a database problem.  The problem is not the comma/period though, so don't worry about that.  

As for your ODBC connection, what UDF are you using for it?  (UDF is an #include file at the top of your script.)  Also, do you have the full version of SciTE?  If not I suggest you download that from the main AutoIt page and open your script, then hit CTRL-F5 to see if it has any errors..

 

And so you know, it is possible to set AutoIt up to work with different countries and how they handle comma/decimals, this is an example for you:

Local $rKey = "HKCU\Control Panel\International"
Local $sThousands = RegRead($rKey, "sThousand"), $sDecimal = RegRead($rKey, "sDecimal")
If $sThousands = -1 Then $sThousands = RegRead($rKey, "sThousand")

MsgBox(0, "Money", _StringAddThousandsSep(123456789/100))


Func _StringAddThousandsSep($sText)
    If Not StringIsInt($sText) And Not StringIsFloat($sText) Then Return 0
    Local $aSplit = StringSplit($sText, "-" & $sDecimal)
    Local $iInt = 1, $iMod
    If Not $aSplit[1] Then
        $aSplit[1] = "-"
        $iInt = 2
    EndIf
    If $aSplit[0] > $iInt Then
        $aSplit[$aSplit[0]] = "." & $aSplit[$aSplit[0]]
    EndIf
    $iMod = Mod(StringLen($aSplit[$iInt]), 3)
    If Not $iMod Then $iMod = 3
    $aSplit[$iInt] = StringRegExpReplace($aSplit[$iInt], '(?<=\d{' & $iMod & '})(\d{3})', $sThousands & '\1')
    For $i = 2 To $aSplit[0]
        $aSplit[1] &= $aSplit[$i]
    Next
    Return $aSplit[1]
EndFunc   ;==>_StringAddThousandsSep

Ian

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Oh, a great, great tanks to you, llewxam :)

You are absolutely right: I didn't give to you my environment :)

Well, now I work on some test script, just to understand what I can do with AutoIt; I've downloaded the last (at the moment) version, 3.4.4, on a Windows Seven 32 bit machine

To be honest, the "problem" comma vs dot is a "not-problem", in my case, because the program I am working on is a simple cash register, and it is acceptable to see a dot instead a comma.

I've do a circumvention to solve this: in the SQL command I've used "FIELD*100 as FIELD", and before move it in the field, simply I divide by 100.

In this way the result is with two decimal, as I need.

Now I will study you script to unterstand your hint: it's seem a little bit complicated to change a little thing like a comma, don't you? :)

Thank again , and have a beautiful week :)

Bye

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...