Page 1 of 1
Specific Procedures ASCII or Unicode
Posted: Tue Mar 22, 2016 6:15 pm
by IdeasVacuum
I don't know if this request is even possible to invoke. What I would like to be able to do, within a project that is compiled as Unicode (default), is to declare one or more Procedures to be compiled as ASCII, which would mean all PB functions within the Procedure would give ASCII results.
For example, default result = 12, Ascii Procedure result = 6:
Re: Specific Procedures ASCII or Unicode
Posted: Tue Mar 22, 2016 11:05 pm
by STARGÅTE
You have already the possibility to use the optional flag with:
Code: Select all
Debug StringByteLength("abcdef", #PB_Ascii)
Re: Specific Procedures ASCII or Unicode
Posted: Wed Mar 23, 2016 1:10 pm
by Thunder93
How I've interrupted this post yesterday. I thought he was asking for means to have the procedure run in ASCII mode under Unicode. Then the requirement to specify ASCII flags with various commands becomes nullified.

Re: Specific Procedures ASCII or Unicode
Posted: Wed Mar 23, 2016 1:55 pm
by IdeasVacuum
...Exactly so Thunder93. It would essentially mean 1 flag for all members of the Procedure.
e.g.
Code: Select all
Procedure_Ascii MyProc(sStringIn.s, sStringOut.s)
... This in my opinion will help to prevent tricky errors where the wrong flag or no flag has been added to any given function.
Also there are functions affected by compilation that do not have a format flag. AESDecoder() for example, where correct format is absolutely critical.
Re: Specific Procedures ASCII or Unicode
Posted: Wed Mar 23, 2016 10:52 pm
by IdeasVacuum
...It works the other way too. In the example below, Procedure WinLang() must be Unicode format. However, the app itself could be processing ASCII Data (including the decoding of license strings for example), and so other Procedures would need to be ASCII format.
Code: Select all
Enumeration
#WinLanguage
#CmbLanguage
#BtnOK
#Font14R
EndEnumeration
LoadFont(#Font14R, "Microsoft Sans Serif", 14, #PB_Font_HighQuality)
Procedure WinLang()
;#-----------------
Protected iItem.i
Protected iFlags.i = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
Protected Dim sLang.s(38)
sLang(00) = "Afrikaans"
sLang(01) = "Albanian"
sLang(02) = "العربية"
sLang(03) = "Беларускі"
sLang(04) = "বাঙ্গালী"
sLang(05) = "Bosanski"
sLang(06) = "Português (Brasil)"
sLang(07) = "Български"
sLang(08) = "中文简体"
sLang(09) = "中文繁体"
sLang(10) = "Hrvatski"
sLang(11) = "Čeština"
sLang(12) = "Dansk"
sLang(13) = "Nederlands"
sLang(14) = "English"
sLang(15) = "Eesti"
sLang(16) = "Pilipino"
sLang(17) = "Suomalainen"
sLang(18) = "Français"
sLang(19) = "Georgian"
sLang(20) = "Deutsch"
sLang(21) = "Ελληνικά"
sLang(22) = "עברית"
sLang(23) = "हिंदी"
sLang(24) = "Magyar"
sLang(25) = "Icelandic"
sLang(26) = "Bahasa Indonesia"
sLang(27) = "Italiano"
sLang(28) = "日本の"
sLang(29) = "Korean"
sLang(30) = "Latviski"
sLang(31) = "Lietuviu"
sLang(32) = "Македонски"
sLang(33) = "Melayu"
sLang(34) = "Malti"
sLang(35) = "Norsk"
sLang(36) = "فارسی"
sLang(37) = "Polski"
sLang(38) = "Português (Portugal)"
If OpenWindow(#WinLanguage, 0, 0, 382, 42, "", iFlags)
ComboBoxGadget(#CmbLanguage, 10, 6, 316, 32)
ButtonGadget(#BtnOK, 334, 6, 42, 32, "OK")
For iItem = 0 To 38
AddGadgetItem(#CmbLanguage, iItem, sLang(iItem))
Next
SetGadgetFont(#CmbLanguage, FontID(#Font14R))
SetGadgetState(#CmbLanguage, 0)
EndIf
EndProcedure
Procedure WaitForUser()
;#---------------------
Protected iEvent.i, iExit.i = #False
Repeat
iEvent = WaitWindowEvent(1)
If(iEvent = #PB_Event_CloseWindow) : iExit = #True : EndIf
If(iEvent = #PB_Event_Gadget) And (EventGadget() = #BtnOK) : iExit = #True : EndIf
Until iExit = #True
EndProcedure
WinLang()
WaitForUser()
End