PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: CiniFile  (Read 676 times)

SeaVipe

  • Junior Member
  • **
  • Posts: 194
  • Windows 10
CiniFile
« on: August 13, 2018, 11:54:02 PM »

Hi Josť,
Code: [Select]
Dim as CiniFile ini = "C:\BootTime\boottime.ini"
Dim as CWSTR s = Trim( frmMain.txtNotes.Text )
Dim as Boolean boo1 = ini.WriteValue( ct.Format("%Y-%m-%d"), Str(Time) & ".2", Space( 1 ) & s )
Results in the following Error:C:\WinFBE_Suite\Sample_Projects\BootTimeTest\modMain.bas(81) error 98: Ambiguous call to overloaded function, WRITEVALUE() in 'dim as Boolean boo1 = ini.WriteValue( ct.Format("%Y-%m-%d"), Str(Time) & ".2", Space( 1 ) & s )'
Declare s as a String and the result is no error.
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: CiniFile
« Reply #1 on: August 14, 2018, 10:11:13 AM »

Sometimes the "&" string concatenation causes issues with combining FB and CWSTR variables. Change it to the following and it should work:

Space( 1 ) + s

(or more technically correct)
WSpace( 1 ) + s

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3208
Re: CiniFile
« Reply #2 on: August 14, 2018, 10:51:13 AM »

The behaviour of the & operator, tailored to please nostalgics of VB6, can cause problems sometimes because it supports to concatenate numbers with strings. As CWSTR is not a string, but a pointer to a class, the compiler sometimes fails to ascertain if it has to convert the value of the pointer to a string or call the cast operator of the class.