Weird call to format function behavior

Hi everyone,

absolute fresh Windows install & SambaPOS

But [=F()] is not working and neither are scripts.

Can someone help me debug this? First time I ever encountered these errors.

What version of Windows is it? Is it possibly Windows Server 2008? I think you don’t have Windows Script Host installed or enabled.

Have a look here:

1 Like

Windows 10 Pro, fully updated.

SQL Server Express x64 2014

Thanks @markjw, Ill try to install that module tomorrow and see what happens.

I just tried looking for it on my PC that works fine and cant seem to find Windows Components > Windows Scripting Host in Programs & Features on Windows 10.

But I found this in the registry. You reckon I can enable it here?

If Win 10 it won’t be this issue.

Hmm, well the error looks like it cant find a certain module or .dll. @Jesse would you know what is it referring to? Maybe I can copy it from a working PC to this one.

Did you try just reinstalling SambaPOS again?

Show the scripts and the places your using the format expressions.

Its not referring to a sambapos module. It looks like your evoking a reference to a library that does not exist. What are you doing?

On the invoice its this, which works fine on absolutely any other device. As you can see on this device that has the error it doesn’t calculate the exchange rate.

[=F(TN('{TICKET TOTAL}') * 4000)]

Script is working on every other device too. Its only this one that doesn’t. I mean its a fresh Windows 10 Pro install, updates, .NET Framework 3.5 and SambaPOS. I mean its an install recipe I have for every setup so I am sure I didnt miss anything here.

Honestly I could have written this a little bit better but nonetheless it works. You’ll need to get a paid Fixer API key for this to work for you though.

function updaterates()
{


// CHECK IF DEFAULT SETTINGS EXIST, IF FALSE CREATE DEFAULT SETTINGS

var qryKHRexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'KHR'");
var qryCNYexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'CNY'");
var qryEURexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'EUR'");


if(qryKHRexists == false || qryCNYexists == false || qryEURexists == false)
{
	dlg.ShowMessage("Thank you for using our Fixer API integration! Press OK and SambaPOS will setup default settings.")

		if (qryKHRexists == false)
		{
			sql.ExecSql("INSERT INTO [dbo].[ProgramSettingValues] (Name,Value) VALUES ('KHR','4100.00')");
			dlg.ShowMessage("Default KHR setting created");
		}
		

		if (qryCNYexists == false)
		{
			sql.ExecSql("INSERT INTO [dbo].[ProgramSettingValues] (Name,Value) VALUES ('CNY','6.80')");
			dlg.ShowMessage("Default CNY setting created");
		}


		if (qryEURexists == false)
		{
			sql.ExecSql("INSERT INTO [dbo].[ProgramSettingValues] (Name,Value) VALUES ('EUR','0.85')");
			dlg.ShowMessage("Default EUR setting created");
		}

}


// CHECK IF DEFAULT SETTINGS EXIST AGAIN
var qryKHRexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'KHR'");
var qryCNYexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'CNY'");
var qryEURexists = sql.Exists("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [Name] = 'EUR'");



// IF ALL SETTINGS EXIST IN SQL DATABASE, PROCEED TO API

if(qryKHRexists == true && qryCNYexists == true && qryEURexists == true)
{
	dlg.ShowMessage("Fetching USD rates...")
	var nL = "<linebreak/>";
	var apikey = "#################";
	var base = "USD";
	var symbol1 = "KHR";
	var symbol2 = "CNY";
	var symbol3 = "EUR";
	
	// CALL TO FIXER API LATEST END POINT
	
	var u = "http://data.fixer.io/api/latest?access_key="+apikey+"&base="+base+"&symbols="+symbol1+","+symbol2+","+symbol3+"";
	var getrates = web.Download(u);
	
	// IF DOWNLOAD SUCCESSFUL CREATE JSON OBJECT
		if(getrates)
        {
   
            var allrates = JSON.parse(getrates);
            var currentdate = allrates.date;
            var rate1 = allrates.rates.KHR;
            var rate2 = allrates.rates.CNY;
            var rate3 = allrates.rates.EUR;
            	

            	if(allrates.success)
            	{	
            		dlg.ShowMessage("Success!\rUSD rates updated.")
            		var KHRupdate = "UPDATE [ProgramSettingValues] SET [VALUE] ="+rate1+" WHERE [Name] = 'KHR'";
            		sql.ExecSql(KHRupdate);
            		
            		var CNYupdate = "UPDATE [ProgramSettingValues] SET [VALUE] ="+rate2+" WHERE [Name] = 'CNY'";
            		sql.ExecSql(CNYupdate);
            		
            		var EURupdate = "UPDATE [ProgramSettingValues] SET [VALUE] ="+rate3+" WHERE [Name] = 'EUR'";
            		sql.ExecSql(EURupdate);
            		
            		var valueKHR = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'KHR'").First;
					var valueCNY = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'CNY'").First;
					var valueEUR = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'EUR'").First;
            		
                	return tag.Size(25,'<color White> '+base+' 1 = '+symbol1+' '+valueKHR+' </color>')
                	+ nL + tag.Size(25,'<color White> '+base+' 1 = '+symbol2+' '+valueCNY+' </color>')
                	+ nL + tag.Size(25,'<color White> '+base+' 1 = '+symbol3+' '+valueEUR+' </color>');
        		}
        }

	// IF DOWNLOAD FAILS, LOAD PRE-SET SETTINGS
	dlg.ShowMessage("No API response!\rSystem will revert to previous rates.")
	
	var valueKHR = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'KHR'").First;
	var valueCNY = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'CNY'").First;
	var valueEUR = sql.Query("SELECT [VALUE] FROM dbo.[ProgramSettingValues] WHERE [NAME] = 'EUR'").First;
            
	return tag.Size(25,'<color White> '+base+' 1 = '+symbol1+' '+valueKHR+' </color>')
	+ nL + tag.Size(25,'<color White> '+base+' 1 = '+symbol2+' '+valueCNY+' </color>')
	+ nL + tag.Size(25,'<color White> '+base+' 1 = '+symbol3+' '+valueEUR+' </color>');
}

// END OF FUNCTION
}

There is new. Net out. Install the latest. Net and check it. It’s 3.8 I believe

Its late, I had a full day today. So Ill troubleshoot tomorrow and let you guys know what I find after I dig into the problem a little bit more.

This is what I usually have installed.
image

Latest is 4.8 (guess was a typo)

This all looks fine. You only need .net 4.8 for SambaPOS, earlier versions are not needed.

Can you tell me anything else different about this system compared to others, no matter how insignificant?

I assume it isn’t set to run Windows 10 in S Mode? (however if that were the case, you shouldn’t have been able to install SambaPOS until you disable S Mode)

You could try creating a new local admin user and see if it works. If it does it could be something wrong with your user permissions or profile.

Just went back on site to check every thing and compare all the services and stuff compared to my working setup and there is literally nothing different in this setup.

Same setup, same updates, same configuration. I mean, I have no idea whats going on.

Its not running in Safe mode.

I tried adding another Administrator but it didnt work out…

Just wanted to mention that I resolved this issue by reinstalling Windows 10 Pro x64. I am still unsure what happened but I am sure its a freak accident.

After the full reinstall, it works normally. :woman_shrugging:

2 Likes