Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 132
» Latest member: Vicki Massey
» Forum threads: 118
» Forum posts: 907

Full Statistics

Latest Threads
Discussions
Forum: JKB (32/64 bit Compiler)
Last Post: Albert Richheimer
27.04.2026, 19:42
» Replies: 9
» Views: 499
Announcements for updates
Forum: JKB (32/64 bit Compiler)
Last Post: Juergen Kuehlwein
27.04.2026, 14:26
» Replies: 1
» Views: 228
Enter PIN popup dialog in...
Forum: Source Code Library
Last Post: Dale Yarker
23.04.2026, 16:54
» Replies: 0
» Views: 47
Sounds good!
Forum: JKB (32/64 bit Compiler)
Last Post: Dale Yarker
13.04.2026, 02:54
» Replies: 0
» Views: 135
What is different
Forum: JKB (32/64 bit Compiler)
Last Post: Juergen Kuehlwein
12.04.2026, 14:43
» Replies: 0
» Views: 171
How to run own code
Forum: JKB (32/64 bit Compiler)
Last Post: Juergen Kuehlwein
12.04.2026, 14:08
» Replies: 0
» Views: 134
Download and setup
Forum: JKB (32/64 bit Compiler)
Last Post: Juergen Kuehlwein
12.04.2026, 13:51
» Replies: 0
» Views: 192
A new sub-forum for Juerg...
Forum: JKB (32/64 bit Compiler)
Last Post: Juergen Kuehlwein
12.04.2026, 13:26
» Replies: 1
» Views: 198
How many "1" bits /Is Num...
Forum: Source Code Library
Last Post: Dale Yarker
16.03.2026, 11:54
» Replies: 0
» Views: 199
Notepad++ hacked
Forum: This and that - friendly chat
Last Post: Stanley Durham
05.02.2026, 19:03
» Replies: 4
» Views: 1,022

 
  Enter PIN popup dialog in DLL.
Posted by: Dale Yarker - 23.04.2026, 16:54 - Forum: Source Code Library - No Replies

A popup for user to enter a PIN for return to your app. The number of digits is specified in the call, and checked by the function in the DLL.

Longer description
at https://www.yarker-dsyc.info/Programs/Mi...N_DLL.html

Source, compiled, icons and Help file in ZIP
at https://www.yarker-dsyc.info/Programs/Mi...er_PIN.zip

DLL source: 

Code:
#compile dll
#dim all
'================================================================
enum PIN_IDs singular
  '%en_update group
  ID_PINA1Txtbx = &h3000&
  ID_PINA2Txtbx
  ID_PINA3Txtbx
  ID_PINA4Txtbx
  ID_PINA5Txtbx
  ID_PINA6Txtbx
  ID_PINA7Txtbx
  ID_PINA8Txtbx
  ID_PINA9Txtbx
  ID_PINB1Txtbx = &h3010
  ID_PINB2Txtbx
  ID_PINB3Txtbx
  ID_PINB4Txtbx
  ID_PINB5Txtbx
  ID_PINB6Txtbx
  ID_PINB7Txtbx
  ID_PINB8Txtbx
  ID_PINB9Txtbx
  '%bn_clicked group
  ID_PINAExposeBtn
  ID_PINBExposeBtn
  ID_PINSubmitSnglBtn
  ID_PINSubmitDuplBtn
  ID_PINHelp
  ID_PINCanx
  'not selected in callback
  ID_PINInstruLbl
  ID_PINALbl
  ID_PINBLbl                                    'type rect '
end enum 'number up to &h3FF reserved
'
%EM_SETPASSWORDCHAR = &h00CC
%wm_syscommand = &h0112 '(not built into PBWin)
%DT_CalcRect = &h00000400
#resource icon, PIN16, ".\PIN16.ico"
#resource icon, ShowPWon24, ".\ShowPWon24.ico"
#resource icon, ShowPWoff24, ".\ShowPWoff24.ico"
#resource icon, PINSubmit, ".\PINSubmit48.ico"
#resource icon, PINHelp, ".\HelpQuesBtn48.ico"
#resource icon, PINCanx, ".\CancelPIN32.ico"
global gIsVariableDigits, gNumOfDigits as long '(is in PIN_Enter and callback)
global gEntryErrTitle as wstring
declare function ShellExecute lib "Shell32.dll" alias "ShellExecuteW" ( _
    byval hwnd as dword, lpOperation as wstringz, lpFile as wstringz, _
    lpParameters as wstringz, lpDirectory as wstringz, byval nShowCmd as long) _
    as dword

'############################################################# the function ####
function PIN_Enter alias "PIN_Enter" (byval hParent as dword, _
                                      byval DualPIN as long, _
                                      byval NumOfDigits as long) export as dword
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  static Not1stCall, nFontMono14B as long
  static gEntryErrTitle as wstring
  static RatioX, RatioY as single
  local hPIN_Dlg, PIN as dword
  local TBY, TBX, ID_Dig, PosX as long
  local InstruStr, DigCnt as wstring
  '========================================================= initialization ====
  '····························································· persistent ····
  if Not1stCall = 0 then 'so it is first call
    Not1stCall = -1
    font new "Lucida Console", 14, 1, 1, 0, 0 to nFontMono14B
    dialog default font "Segoe UI", 12, 0, 1
    gEntryErrTitle = "PIN Entry Error"$$
  end if
  '······························································ each call ····
  if (NumOfDigits < 0) or (NumOfDigits > 9) then 'check range
    msgbox "The number of PIN digits can only be optionally"$$ + $$crlf + _
           "not used, or 0 to 9 digits long."$$ + $$crlf + _
           "Not used or 0 is for a variable length PIN of"$$ + $$crlf + _
           "1 to 9 digigits. Otherwise the number of digits is"$$ + $$crlf + _
           "fixed by the using program."$$, _
           %mb_ok or %mb_iconerror or %mb_taskmodal, gEntryErrTitle
    exit function
  end if
  if NumOfDigits = 0 then 'variable number
    gIsVariableDigits = -1
    gNumOfDigits = 9
  else
    gNumOfDigits = NumOfDigits
  end if
  '================================================================= dialog ====
  dialog new hParent, "Enter PIN."$$, _
      0, 10, 200, 120, _
     %ds_3dlook or %ds_modalframe or %ds_nofailcreate or %ds_setfont or _
     %ws_caption or %ws_clipsiblings or %ws_dlgframe or %ws_popup or _
     %ws_sysmenu, %ws_ex_left or %ws_ex_ltrreading to hPIN_Dlg
  dialog set icon hPIN_Dlg, "PIN16"
  '------------------------------------------------------- unit/pixel ratio ----
  #if %pb_revision = &h1004
    dialog units hPIN_Dlg, 1000, 1000 to pixels TBY, TBX 'precycle longs
  #else
    dialog units hPIN_Dlg, 1000, 1000 to pixels TBX, TBY
  #endif
  RatioX = 1000 /TBX : RatioY =  1000 / TBY 'mult img px for button units
  '------------------------------------------------------------- PIN instru ----
  if DualPIN then
    InstruStr = "The application requires dual entry for the requested "$$ + _
                "task. "$$
  end if
  if NumOfDigits then
    InstruStr +="Enter the "$$ + dec$(gNumOfDigits) + " digit PIN. "$$
  else
    InstruStr += "The number of digits is not fixed. The PIN may be 4 "$$ + _
                 "to 9 digits. Leave unused digits at right empty. "$$
  end if
  InstruStr += "The only characters allowed are ""0"" to ""9""."$$
  control add label, hPIN_Dlg, %ID_PINInstruLbl, InstruStr,  _
     5, 4, 185, 34, %ss_left, %ws_ex_left
  control set color hPIN_Dlg, %ID_PINInstruLbl, -1, &hFAFAFA
  '---------------------------------------------------- "A" digit textboxes ----
  control add label, hPIN_Dlg, %ID_PINALbl, "Enter PIN:"$$, _
     4, 45, 42, 10, %ss_right, %ws_ex_left   ''55
  '
  PosX = 49
  for ID_Dig = %ID_PINA1Txtbx to %ID_PINA1Txtbx + gNumOfDigits - 1
    control add textbox, hPIN_Dlg, ID_Dig, ""$$, _
       PosX, 44, 12, 10, %es_center or %es_number or %ws_border or _
       %ws_tabstop or %es_password, %ws_ex_clientedge or %ws_ex_left
    control set font hPIN_Dlg, ID_Dig, nFontMono14B
    PosX += 15
  next
  '
  control add imgbutton, hPIN_Dlg, %ID_PINAExposeBtn, "ShowPWon24", _
     181, 43, 28 * RatioX, 28 * RatioY
  if DualPIN = 0 then
    control add imgbutton, hPIN_Dlg, %ID_PINSubmitSnglBtn, "PINSubmit", _
       49 - (52 * RatioX), 59, 52 * RatioX, 52 * RatioY
   ' dialog set size hPIN_Dlg, 200, 75 + (52 * RatioY)
  else
  '---------------------------------------------------- "B" digit textboxes ----
    PosX = 49
    control add label, hPIN_Dlg, %ID_PINBLbl, "Reenter PIN:"$$, _
       4, 60, 42, 10, %ss_right, %ws_ex_left   ''55
    for ID_Dig = %ID_PINB1Txtbx to %ID_PINB1Txtbx + gNumOfDigits - 1
      control add textbox, hPIN_Dlg, ID_Dig, ""$$, _
         PosX, 60, 12, 10, %es_center or %es_number or %ws_border or _
         %ws_tabstop or %es_password, %ws_ex_clientedge or %ws_ex_left
      control set font hPIN_Dlg, ID_Dig, nFontMono14B
      PosX += 15
    next
  '
    control add imgbutton, hPIN_Dlg, %ID_PINBExposeBtn, "ShowPWon24", _
       181, 59, 28 * RatioX, 28 * RatioY
    control add imgbutton, hPIN_Dlg, %ID_PINSubmitDuplBtn, "PINSubmit", _
       49 - (52 * RatioX), 75, 52 * RatioX, 52 * RatioY
  end if
  '----------------------------------------------------- "A" and "B" common ----
  if DualPIN = 0 then
    control add imgbutton, hPIN_Dlg, %ID_PINHelp, "PINHelp", _
       191 - (99 * RatioX), 59, 52 * RatioX, 52 * RatioY
    control add imgbutton, hPIN_Dlg, %ID_PINCanx, "PINCanx", _
       191 - (36 * RatioX), 59 + (16 * RatioY), (36 * RatioX), (36 * RatioY)
    dialog set size hPIN_Dlg, 200, 76 + (52 * RatioY)
  else
    control add imgbutton, hPIN_Dlg, %ID_PINHelp, "PINHelp", _
       191 - (99 * RatioX), 75, 52 * RatioX, 52 * RatioY

    dialog set size hPIN_Dlg, 200, 92 + (52 * RatioY)
    control add imgbutton, hPIN_Dlg, %ID_PINCanx, "PINCanx", _
       191 - (36 * RatioX), 75 + (16 * RatioY), (36 * RatioX), (36 * RatioY)
  end if
  '
  dialog show modal hPIN_Dlg call  PINDlgCB to PIN
  function = PIN
end function
'================================================================= callback ====
callback function PINDlgCB() as long
  static A_IsExposed, B_IsExposed as long
  static PINStr as wstring
  local TmpL as long
  local TmpS as wstring
  if cb.msg = %wm_command then
    if cb.ctlmsg = %en_update then
      if (cb.ctl >= %ID_PINA1Txtbx) and (cb.ctl <= %ID_PINB9Txtbx) then
        if (gNumOfDigits - 1) > (&h00000F and cb.ctl) then
          control set focus cb.hndl, cb.ctl + 1
        else
          control set focus cb.hndl, %ID_PINB1Txtbx
        end if
      end if
    elseif cb.ctlmsg = %bn_clicked then
      select case as const cb.ctl
        case %ID_PINAExposeBtn
          if A_IsExposed then 'unexpose
            for TmpL = %ID_PINA1Txtbx to %ID_PINA9Txtbx
              control send cb.hndl, TmpL, %EM_SETPASSWORDCHAR,_
                 &h2A, 0
            next
            control set imgbutton cb.hndl, %ID_PINAExposeBtn, "ShowPWon24"
            A_IsExposed = 0
          else 'expose
            for TmpL = %ID_PINA1Txtbx to %ID_PINA9Txtbx
              control send cb.hndl, TmpL, %EM_SETPASSWORDCHAR, 0, 0
            next
            control set imgbutton cb.hndl, %ID_PINAExposeBtn, "ShowPWoff24"
            A_IsExposed = -1
          end if
          for TmpL = %ID_PINA1Txtbx to %ID_PINA9Txtbx
            control redraw cb.hndl, TmpL
          next
        case %ID_PINBExposeBtn
          if B_IsExposed then
            for TmpL = %ID_PINB1Txtbx to %ID_PINB9Txtbx
              control send cb.hndl, TmpL, %EM_SETPASSWORDCHAR,_
                 &h2A, 0
            next
            control set imgbutton cb.hndl, %ID_PINBExposeBtn, "ShowPWon24"
            B_IsExposed = 0
          else 'expose
            for TmpL = %ID_PINB1Txtbx to %ID_PINB9Txtbx
              control send cb.hndl, TmpL, %EM_SETPASSWORDCHAR, 0, 0
            next
            control set imgbutton cb.hndl, %ID_PINBExposeBtn, "ShowPWoff24"
            B_IsExposed = -1
          end if
          for TmpL = %ID_PINB1Txtbx to %ID_PINB9Txtbx
            control redraw cb.hndl, TmpL
          next
        '············································· submit single button ····
        case %ID_PINSubmitSnglBtn, %ID_PINSubmitDuplBtn
          control get text cb.hndl, %ID_PINA1Txtbx to TmpS
          PINStr = TmpS
          for TmpL = 1 to 8
            control get text cb.hndl, %ID_PINA1Txtbx + TmpL to TmpS
            PINStr += TmpS
          next
          TmpL = len(PINStr)
          if gIsVariableDigits then
            if Tmpl < 4 then
              msgbox "Varible length PINs must be 4 to 9 digits "$$ + _
                     "and exactly the same as when it was created."$$, _
                     %mb_ok or %mb_iconerror or %mb_taskmodal, gEntryErrTitle
              exit function
            end if
          else
            if TmpL < gNumOfDigits then
              msgbox "The program using this PIN requires "$$ + _
                     dec$(gNumOfDigits) + " digits."$$, _
                     %mb_ok or %mb_iconerror or %mb_taskmodal, gEntryErrTitle
              exit function
            end if
          end if
          if cb.ctl = %ID_PINSubmitDuplBtn then
            for TmpL = 0 to 8
              control get text cb.hndl, %ID_PINB1Txtbx + TmpL to TmpS
                if TmpS = mid$(PINStr, TmpL + 1, 1) then
                  iterate for
                else
                  msgbox "The and the repeat do not match."$$, _
                         %mb_ok or %mb_iconerror or %mb_taskmodal, _
                         gEntryErrTitle
                  exit function
                end if
              next
          end if
          if gIsVariableDigits then
            TmpL = 9 - len(PINStr)
            PINStr += string$$(TmpL, "0"$$)
          end if
          dialog end cb.hndl, val(PINStr)
        case %ID_PINHelp
         '' ShellExecute
            ShellExecute (0, "open"$$, "PIN_Enter_Help.html", ""$$, ""$$, %sw_shownormal)
        case %ID_PINCanx
          goto NoPIN
      end select
    end if
  elseif (lo(word, cb.wparam) = %sc_close) and (cb.msg = %wm_syscommand) then
    goto NoPIN
  end if
  exit function
  NoPIN:
  TmpL = msgbox("""Yes"", to quit PIN entry."$$ + $$crlf + _
                """No"", to stay and enter a PIN."$$, _
            %mb_yesno or %mb_iconquestion or %mb_defbutton2 or %mb_taskmodal, _
            "Verify Quitting PIN Entry"$$)
  if TmpL = %idno then
    function = -1
  else
    dialog end cb.hndl
  end if
end function
Demo source: 
Code:
'File PIN_SLL_demo.bas
#compile exe
#dim all
#if %def(%pb_cc32)
  #console off
#endif
declare function PIN_Enter lib "EnterPIN.dll" alias "PIN_Enter" _
                                            (byval hParent as dword, _
                                             byval DuplPIN as long, _
                                             byval NumOfDigits as long) as dword
function pbmain () as long
  local hTWin, PIN as dword
  local Rspnc as wstring
  txt.window("PIN Enter Popup Demonstration"$$, 400, 70, 20, 75) to hTWin
  txt.color = %rgb_green
  txt.print "At any wait use any key to continue. (like now :) )"$$
  txt.waitkey$
  '
  txt.color = %rgb_blue
  txt.print "A dual PIN entry with number of digits set to 4. "$$;
  txt.color = %rgb_black
  txt.print "Returned PIN is: "$$ + dec$(PIN_Enter(hTWin, 1, 4), 4)"."$$
  txt.color = %rgb_green
  txt.print
  txt.print "Any key to continue."
  txt.waitkey$
  '
  txt.color = %rgb_blue
  txt.print "A single PIN entry with number of digits set to 4. "$$;
  txt.color = %rgb_black
  txt.print "Returned PIN is: "$$ + dec$(PIN_Enter(hTWin, 0, 4), 4)"."$$
  txt.print
  txt.color = %rgb_green
  txt.print """ESC"" to end demo, any other key to continue with next."
  Rspnc = txt.waitkey$
  if Rspnc = $$esc then exit function
  '
  txt.color = %rgb_blue
  txt.print "Number of PIN digits set to 9. "$$;
  txt.color = %rgb_black
  txt.print "Returned PIN is: "$$ + dec$(PIN_Enter(hTWin, 0, 9), 9)"."$$
  txt.color = %rgb_blue
  txt.print "You had to enter 9 digits, or ""Cancel PIN"" to get here."$$
  txt.print
  txt.color = %rgb_green
  txt.print """ESC"" to end demo, any other key to continue with next."
  Rspnc = txt.waitkey$
  if Rspnc = $$esc then exit function
  txt.color = %rgb_blue
  txt.print "Number of PIN digits set to 0 (user preference). "$$
  txt.print "Looks like previous, but 4 to 9 digits allowed."$$;
  txt.print "Returned PIN is: "$$ + dec$(PIN_Enter(hTWin, 0, 0), 9)"."$$
  '

  '---------------------------------------------------------------------
  txt.color = %rgb_green
  txt.print
  txt.print "Any key will close."$$
  txt.waitkey$
end function

Print this item

  Announcements for updates
Posted by: Juergen Kuehlwein - 13.04.2026, 16:16 - Forum: JKB (32/64 bit Compiler) - Replies (1)

There is an improved version of the experimental code converter for JKB (JKB_Convert.exe), please download the update package (update.zip) and unpack over your existing installation.

Print this item

  Sounds good!
Posted by: Dale Yarker - 13.04.2026, 02:54 - Forum: JKB (32/64 bit Compiler) - No Replies

From: What´s different

Quote:The syntax is (with some minor restrictions) compatible to PowerBASIC. These restrictions are:
The bit that caught my interest

Quote:- Variables must not be declared with "DIM" anymore! ...  Dim is exclusively used for dimensioning arrays.
 Big agreement and self-imposed in my code.

   
Quote:THREADED is not supported ATM.
Aww, when thread is needed it is needed. Since I seldom need it its not a big handicap for now.

Quote:- You may still declare multiple variables of the same data type in one single line. "LOCAL a, b, c AS LONG" is accepted. "LOCAL a$, b AS DWORD, c AS LONG" throws an error, because a$, b and c represent different data types.
Also self-imposed.

I'll download now.  Smile I need to get closer to the bottom of "job jar" to try it.  Sad

Print this item

  What is different
Posted by: Juergen Kuehlwein - 12.04.2026, 14:43 - Forum: JKB (32/64 bit Compiler) - No Replies

What´s different

The syntax is (with some minor restrictions) compatible to PowerBASIC. These restrictions are:


- Variables must not be declared with "DIM" anymore! 
    LOCAL, GLOBAL, STATIC, INSTANCE or COMMON is required (= #DIM ALL in PB)!. Dim is exclusively used for dimensioning arrays. THREADED is not supported ATM.

- You may still declare multiple variables of the same data type in one single line. "LOCAL a, b, c AS LONG" is accepted. "LOCAL a$, b AS DWORD, c AS LONG" throws an error, because a$, b and c represent different data types.


- You may assign an intial value, e.g. "LOCAL x AS LONG = -1"


- With variables you cannot have type specifiers anymore except for "$" (dynamic ANSI string) or "$$" (dynamic wide string)


- There are new data types: QWORD (unsigned 64 bit integer), SBYTE (signed 8 bit integer), XWORD (DWORD in 32 bit and QWORD in 64), XLONG (LONG in 32 bit and QUAD in 64)


- Assembler code:   
    ! cmp byte [esi], 0  -> byte ptr (the key word "ptr" is mandatory, assembler error otherwise)
    ! ret must become,  ! retn, (ret ends a stackframe)

    !.if (eax == 0)
    ! ... "
    !.endif                     (MASM Hi-level syntax is possible)

    XAX = EAX in 32 bit and RAX in 64 bit


- Reserved words: there is a list of words, which are forbidden as variable or procedure names, eg. pos, count, enter, comment et. al


- String expressions: no logical string expressions, but automatic build$
    e.g.        if a$ < b$ and c$ < d$ then
                 ...
           
    must be    if a$ < b$ then
                      if c$ < d$ then
                      ...
             
    but a$ + b$ + c$, is always compiled as BUILD$(a$, b$, c$), BUILD$ is valid syntax, but it is not necessary anymore             



- Conditional compiling: code inside conditional compiling blocks (even if condition is not met) must be compilable
    you cannot code anymore:
    #IF 0
    <your comments here> -> you must pepend an apostrophe to make it a comment
    #ENDIF


#TRACE, #PROFILE and #CALLSTACK make use of the OutputDebugString Viewer, this is still experimental


- Syntax:
PARSE        (no special treatment for default separator "," and quotes)

ISTRUE      (parenthesis are required, it´s a function not an operator)
ISFALSE      (parenthesis are required, it´s a function not an operator)

FORMAT$      (only one formatting mask allowed)
JOIN$        (without BINARY option and special quote handling)
PARSE$      (without BINARY option and special quote handling)

PRINT        (requires sparator (, ; spc() tab()) between expressions)



What´s new:

#SEH - in case of a GPF, the offending line is shown in the IDE

TIMING [END]  -  return elapsed time in µs, syntax: TIMING [END] qword/quadvar
ISVALID(<ptr>) -  returns -1, if pointer points to valid memory, 0 otherwise

SIN            -  y = SIN([deg/rad], x) default is deg, applies to all trigonometric functions

ZIP:                                                                                  'zip into ziparchive
' ZIP string s$, filename (in ziparchive), ziparchive [, password] [, call callback]
' ZIP filename(s), ziparchive [, password] [, call callback]
' ZIP memory ptr, len, filename (in ziparchive), ziparchive [, password] [, call callback]
ZIP$:                                                                                  'zip into string
' z$ = ZIP$(string s$, filename (in archive) [, password] [size = x] [, call callback])
' z$ = ZIP$(filename(s) [, password] [size = x] [, call callback])
' z$ = ZIP$(memory ptr, len, filename (in archive) [, password] [size = x] [, call callback])
UNZIP:                                                                                'unzip ziparchive
' UNZIP filename(s) (in string), string s$ [, password] [to folder] [, call callback]
' UNZIP filename(s) (in ziparchive), ziparchive [, password] [to folder] [, call callback]
' UNZIP filename(s) (in memory), memory ptr, len [, password] [to folder] [, call callback]
UNZIP$                                                                                'unzip into string
' s$($) = UNZIP$(filename (in string), string z$|ziparchive] [, password])
' s$($) = UNZIP$(filename (in ziparchive), ziparchive] [, password])
' s$($) = UNZIP$(filename (in memory), memory ptr, len|ziparchive] [, password])
ZIPINFO:                                                                              'return # of files in zip + array of zipinfo
' x = ZIPINFO(array, string z$|ziparchive [, password])           
' x = ZIPINFO(array, memory ptr, len|ziparchive [, password])
ZIPCALC:                                                                              'return # of bytes for zipped data
' x = ZIPCALC(string s$|filename(s))
' x = ZIPCALC memory ptr, len|filename(s)
UNZIPCALC:                                                                            'return # of bytes for unzipped data
' x = UNZIPCALC( filename(s), string z$|ziparchive [, password])
' x = UNZIPCALC( filename(s), memory pointer, len|ziparchive [, password])



Run 32 bit code:
As a first step try to run 32 bit code. Please adapt your code according to the above restrictions. If there are many places to adapt, the Replace Dialog (Ctrl + R) is your friend. The first line must be "#COMPILER JKB [32]", "F9" compiles and executes. The IDE will complain about errors.


Run 64 bit code:
64 bit code definitely needs adaptions: all pointers and handles (which are pointers in fact) must become 64 bit data types (DWORD -> XWORD and LONG -> XLONG). The first line must be "#COMPILER JKB 64".



There is a (still experimental) code converter (Credits to Norbert Spoerl for supplying ideas and major parts of code) for adapting existing code to the new requirements. You may use the menu (last item in "File" menu: "Prepare Source for JKB" ) or the top toolbar (a new button, next to the "command prompt" button on the right side). This feature is applied to current file in the IDE. A copy (<name>.original) is made before. Yet you may still have to adapt some things manually.



Please don´t post in this thread, feel free to ask questions in "Discussions" thread

Print this item

  Discussions
Posted by: Juergen Kuehlwein - 12.04.2026, 14:09 - Forum: JKB (32/64 bit Compiler) - Replies (9)

Please use this thread for asking all kinds of questions!

Print this item

  How to run own code
Posted by: Juergen Kuehlwein - 12.04.2026, 14:08 - Forum: JKB (32/64 bit Compiler) - No Replies

My IDE makes extensive use of hot keys, type CTRL + H for a list of key combinations

In the IDE´s folder there is a file (list of available features.txt) listing all currently supported statements. Most statements are compatible to PB syntax

I´m not absolutely sure, if my implementation of macros works correct under all circumstances, the same applies to math functions and all kinds of expressions, especially with new data types like QWORD and SBYTE. I am sure there will be bugs, issues and problems i didn´t find yet!


Compiling the same code for 32 and 64 bit requires a special data type, which represents 32 bit in 32 bit and 64 bit in 64 bit: XWORD (unsigned) and XLONG (signed). Therefore all include files (i used José´s) must be prepared for this. Currently not all but about 2/3 have been translated and can be found in \Basic\Include_new.

64 bit code is much more picky about alignment, 64 bit code refuses to work, if structure alignment is not correct. This produces hard to find errors, and i´m not sure if all structures have been translated properly for 64 bit.

Inline assembler works as usual, i build ebp/rbp based stackframes and you can use PUSH and POP as usual, but in 64 bit code the stack pointer (rsp) must be 16 byte aligned before calls, otherwise you will experience all kinds of crashes. You may replace e/r by x for registers in order to write code, which compiles in 32 and 64 bit. Internally xax becomes eax in 32 bit and rax in 64 bit, this applies to all standard 32 bit registers (eax, ebx, ecx, edx, esi, edi, ebp, esp), obviously you cannot use r8 - r15 in 32 bit code.


In 32 bit code the constant %x32_code and in 64 bit code %x64_code are predefined, so you can build conditional compiling blocks like:

#ifdef %x64_code

... 64 bit code goes here (must be compilable)

#else

... 32 bit code goes here (must be compilable)

#endif


While PowerBASIC allows for (variable)names like "cx" or "si", which are valid register names, my implementation currently doesn´t. So you must use different names. ATM there are some more words (in addition to language keywords), which are forbidden. You will get an error message in such cases.


My object and COM implementation may need improvement, the focus was on being able to use COM services, which seems to work.Writing COM servers is possible but with some restrictions. Inheritance and multiple interfaces are not handled absolutely correct, i fear. There is nothing like #TLIB and "ME." (an object calling itself) doesn´t work yet.
I want better error reporting, in many places you will get a simple "syntax error". It is possible to have more specific messages and i plan to do that, but it is not on top of my priority list.


There are many ways of improving and optimizing my code, but for the moment the most important thing is making the "core" things stable.

Then will be the time to add more features, currently it supports, what i would call the "core" features of a BASIC language. Feel free to ask for "core" features i might have missed. But i won´t add more or less "special" things, before the core can be considered actually stable. At the current point of development i must thoroughly test, what i have in order to avoid changes in the core functionality later on. Code generation must cover different scenarios, the currently supported feature set covers all these scenarios in (hopefully) all it´s aspects. So it should be suited for testing and finding bugs i missed. Further development will then be a variation or implementation of the existing core of code.

E.g when passing arguments, such an argument can be: a literal, a constant, a variable, an array (as a whole, or as one single element), a structure (as a whole, or as one member of it), nested structures, a pointer, a resolved pointer, procedure returns, intrinsic functions (results from key words) and combinations and expressions of all of this. An argument can be passed "byref", "byval" and "bycopy". So there is a variety of possibilities, which must be taken care of.

The most simple code for own tests would be:

Code Select
Code:
#COMPILER JKB 32
#COMPILE EXE

FUNCTION MAIN

...

END FUNCTION


Now you can fill in the body of MAIN (for convenience PBMAIN is also possible) with declarations of variables and code using the syntax known form PB. You can add subs and functions as usual. You may add "#INCLUDE "Win32Api.inc" for access to predefined constants and the Windows API.

About 2/3 of José´s include files are already adapted to work in 64 bit Windows. There might still be issues though


"F9" will start the code generation and if this was successful, start the compiled executable. AV will often not be you friend here! You may add resources by "#RESOURCE "<resourcefilename>.res", but even adding a version control block and a manifest does not ensure smooth testing.

When there are syntax errors inside the BASIC code, these errors are shown in the IDE. In case of no error so far, the generated assembler code is passed to an assembler and linker, errors are shown in the IDE. Finally the created executable is run.

For debuging you can inspect final or intermediate results with "MSGBOX", use "STR$" or "HEX$" for numeric results, or you can make use of "ODS" or "ODX", which show debug output in a special viewer, which doesn´t block code flow like a message box.


Basically everything listed in features is allowed as syntax element. Expressions and block constructs have a maximum nesting level of 64.

The generated assembler code still has potential for optimizing, but (as already mentioned) first i want to get it working and then i want to make it smaller, faster, whatever...

The IDE will create a bunch of extra files mostly for debugging purposes, these will not be visible anymore in a final state.



Please don´t post in this thread, use the "Discussions" thread. More explanations will follow as needed.

Print this item

  Download and setup
Posted by: Juergen Kuehlwein - 12.04.2026, 13:51 - Forum: JKB (32/64 bit Compiler) - No Replies

Hi all,

Below are a link and instructions for a setup - have fun


whole package:  https://www.dropbox.com/scl/fi/tc6syg81r...pbwwe&dl=1
update package:  https://www.dropbox.com/scl/fi/cl6294npc...bwzsq&dl=1



The .zip file is about 40 MB and contains an updated version of my IDE and the complete tool chain necessary for the new "compiler". In fact working together with my IDE this is a complete compiler toolchain creating Windows executables (internally it is a code converter creating assembler code, which in turn is assembled to standard COFF .obj files and then linked to an execuatable). There is a linker (PoLink64.exe) included. A better choice would be Mircosoft´s linker (link.exe + a bunch of dlls), but this linker is not redistributable. It is included in a (free) community version of Visual C. You may download and install VC to have it installed on your machine. For using it you must specify this executable in Path Options Dialog in my IDE. A typical location for VC22 would be: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx86\x86\link.exe.

There might be problems with AV scanners, even Windows Defender sees some versions of JK-Basic.exe (the "compiler") as a potential threat, while virustotal sees no problem. In Windows 11 .exe files might not run, because there is no digital signature. The IDE itself (jk-ide.exe) and the "compiler" (jk-basic.exe) are not digitally signed, and newly created executables will have no digital signature, except you can digitally sign them yourself (the IDE can do that, if you have a certificate).

As usual you can expand the package to a directory of your choice, it is path independent. I recommend a new location, if you already use my IDE. This version is still experimental, so in order not to destroy your work with an existing install, don´t just unpack this over it. Please don´t select a path way down in your folder tree, because there still is a limit in length for paths, which could come into play, if your install path is too long.


When expanding Windows defender (or other AV) might block or quarantine some of the files, so be sure you got them all. In Windows 10 and below it is sufficient to add the "root" directory of this package to the AV´s exception list. I recommend doing this, because to my experience every now and then AV will "butt in" and produce all kinds of strange errors. Sometimes it can be really hard to get such false positives out of quaratine and get it to work again. The package doesn´t contain any dangerous or malicious things. Fell free to re-check with virustotal.

Currently the tool chain only works with my IDE (jk-ide.exe), so you must be or make yourself familiar with it. There is a quite comprehensive help file (menu -> help\JK-IDE Help)


For a start i would like you to do the following things:

- download (full package, the "update package" is for updates, which requires only a subset of files to be replaced)

- unzip

- run jk-ide.exe (you maybe will be asked to specify a path for the PB compiler and for an include file set, please fill in the necessary paths and press "Apply". This happens only, if the IDE cannot find these paths itself)

- the IDE will do some internal setup work, don´t worry, this is expected. It will tell you, when it is finished.

- open "File" menu, select "New As" and "JKB", name and save this source file wherever you want, press "F9". Congratulations, you should have compiled your first 64 bit executable with JKB



Please tell me, if this doesn´t work as described in "Discussions" thread. Don´t post in this thread!

Print this item

  A new sub-forum for Juergen Kuehlwein's JKB (32/64 bit Compiler)
Posted by: Albert Richheimer - 12.04.2026, 07:36 - Forum: JKB (32/64 bit Compiler) - Replies (1)

Welcome to the new sub-forum for Juergen Kuehlwein's JKB. Juergen is going public with his new JKB (32/64 bit Compiler). Please follow the usual PUMP rules for posting in this area.

Cheers,
Albert (PUMP admin)

Print this item

  How many "1" bits /Is Number a Power of 2
Posted by: Dale Yarker - 16.03.2026, 11:54 - Forum: Source Code Library - No Replies

Code:
'The FASTPROCs here are for both PBWin 10 and PBCC 6.
'For older PB versions change FASTPROC to FUNCTION.
'The demo (in PBMAIN below) would need significant change to compile in older
'versions of PB.
#compile exe
#dim all
#if %def(%pb_cc32) 'ignore this in PBWin
  #console off     'no unneeded in PBCC
#endif
'
'#### Please start thread in Programming for comments/questions. ####
'
'I want a solitare game that was not in old PB formum Source Code.
'Do it myself.
'That requires shuffling cards. Instead of repeating shuffle code for other
'games make a DLL.
'Shuffling requires PRNG(s), and seeds for PRNDs. They are useful for more
'than just card game, so another DLL.
'One of the PRNG algorithms fails if seed is a power of 2.
'
'(PRNG is pseudo Random Number Generator, NUT is Number Under Test.)
'
'How many bits are "1"?
''Simple use of the assembly POPCNT needed in power of 2 procs.
''is DWORD/LONG agnostic
fastproc BitCount(byval NUT as long) as long
  ! popcnt eax, NUT
  ! mov NUT, eax
end fastproc = NUT
'
'Is a DWORD number a power of 2?
fastproc IsPowerOf2Dw (byval NUT as long) as long
  ! mov ebx, NUT        'so not to modify NUT
  ! and ebx, &h00000001 'without this 1 returns as PO2
  !  jz IsEven
  ! jmp NotPO2
  IsEven:
  ! popcnt ebx, NUT
  ! cmp ebx, 1
  ! jne NotPO2
  ! mov NUT, -1
  ! jmp Done
  NotPO2:          '   -4 -8
  ! mov NUT, 0
  Done:
end fastproc = NUT
'
'Is a LONG number a power of 2?
''(Second procedure because in DWORD bit 31 is MSB of the number, while
'''in a LONG it is the sign flag and remaining bits are in 2s compliment
'''format.)
fastproc IsPowerOf2Lg (byval NUT as long) as long
  'check if NUT is negative
  !  bt NUT, 31
  ! jc NotPO2
  ! mov ebx, NUT
  ! and ebx, &00000001
  !  jz IsEven
  ! jmp NotPO2
  IsEven:
  ! popcnt ebx, NUT
  ! cmp ebx, 1
  ! jne NotPO2
  ! mov NUT, -1
  ! jmp Done
  NotPO2:
  ! mov NUT, 0
  Done:
end fastproc = NUT
'
'###############################################################################
function pbmain () as long
  local hTWin, NumD as dword
  local NumL, Retrn as long
  txt.window("BitCount, IsPowerOf2Dw and IsPowerOf2Lg"$$, 75, 50, 27, 40) _
                                                                        to hTWin
  '
  txt.color = %rgb_blue : txt.print "BitCount" : txt.color = %rgb_black
  NumL = 1 : Retrn = BitCount(NumL) : gosub PrintCount
  NumL = 2 : Retrn = BitCount(NumL) : gosub PrintCount
  NumL = 15 : Retrn = BitCount(NumL) : gosub PrintCount
  NumL = &h80050006 : Retrn = BitCount(NumL) : gosub PrintCount
  '
  txt.print : txt.color = %rgb_blue
  txt.print "Is DWORD a power of 2?"$$ : txt.color = %rgb_black
  NumD = 1 : Retrn = IsPowerOf2Dw(NumD) : gosub PrintDwd
  NumD = 4 : Retrn = IsPowerOf2Dw(NumD) : gosub PrintDwd
  NumD = 5 : Retrn = IsPowerOf2Dw(NumD) : gosub PrintDwd
  NumD = 4294967294 : Retrn = IsPowerOf2Dw(NumD) : gosub PrintDwd
  '
  txt.print  : txt.color = %rgb_blue
  txt.print "Is LONG a power of 2?"$$ : txt.color = %rgb_black
  NumL = 1 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = -1 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = 8 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = -8 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = 128 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = -128 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = 1024 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = -1024 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = 1026 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  NumL = -11026 : Retrn = IsPowerOf2Lg(NumL) : gosub PrintLng
  '
  txt.print
  txt.color = %rgb_green
  txt.print "Any key to close."$$
  txt.waitkey$
  exit function
  PrintCount:
    txt.print dec$(NumL) + " has " + dec$(Retrn) + " ""1"" bits."
  return
  PrintDwd:
    txt.print dec$(NumD);
    if Retrn then
      txt.print " is"$$
    else
      txt.print " is not"$$
    end if
  return
  PrintLng:
    txt.print dec$(NumL);
    if Retrn then
      txt.print " is"$$
    else
      txt.print " is not"$$
    end if
  return
end function
'#### Please start thread in Programming for comments/questions. ####

Print this item

  Notepad++ hacked
Posted by: Stanley Durham - 03.02.2026, 03:36 - Forum: This and that - friendly chat - Replies (4)

Chinese Hackers Remote Executed Code Via Notepad++ for 6 Months
_______________________________________________________

Please do not post any Youtube links (and others) without comment.

Thank you
Albert (PUMP admin)

Print this item