0

I'm a Technical Writer going through our application's documentation and I came across some issues trying to get some existing Cypress Enable code snippets to work.

We have a stripped-down version of the VBA editor and compiler in our application. When I try to run a couple of programs using some of the statements, I never get the results I'm expecting, or nothing happens.

For example, when I run this script to test the Declare statement, instead of getting a dialog, nothing happens:

Declare Function GetFocus Lib "User32" () As Integer
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (Byval hwnd As Long, Byval lpstring As String, Byval lpstrlen As Long)

Sub Main
   Dim hWindow%
   Dim str1 As String *51
   Dim str2 As String *25
   hWindow% = GetFocus()
   Print "GetWindowText returned: " & GetWindowText( hWindow%, str1, 51)
   Print "GetWindowText2 returned: " & GetWindowText( hWindow%, str2, 25)
   Print str1
   Print str2
End Sub

For the first print statement (Print str1), I'm expecting a MessageBox with: Title = "Enable Scripting Language Editor" Body text = "GetWindowText returned: 50" A single OK button.

With this code to test the DlgFocus statement, no matter which of the OK/Cancel controls I click, the dialog just shuts down:

Sub Main()
   Dim ListBox1$()
   Begin Dialog UserDialog ,,112,74,"Untitled",.DlgProc
      TextBox 12,20,88,12,.TextBox1
      OKButton 12,44,40,14
      CancelButton 60,44,40,14
      Text 12,11,88,8,"Enter Desired Salary:",.Text1
   End Dialog
   Dim d As UserDialog
   Dialog d
End Sub

Function DlgProc(ControlName$,Action%,SuppValue%) As Integer
   If Action% = 2 and ControlName$ = "OK" Then
      If IsNumeric(DlgText$("TextBox1")) Then
         Msgbox "Duly Noted."
      Else
         Msgbox "Sorry, you must enter a number."
         DlgFocus "TextBox1"
         DlgProc = 1
      End If
   End If
End Function

In this version to test the DlgFocus statement, no matter which control I click, the value returned is always zero:

Sub Main
   Begin Dialog UserDialog 200,120,"Script #9",.DialogFunc
      Text 10,10,180,15,"Please push the OK button"
      TextBox 10,40,180,15,.Text
      OKButton 30,90,60,20
      PushButton 110,90,60,20,"&Hello"
   End Dialog
   Dim dlg As UserDialog
   Print Dialog(dlg)
   MsgBox "Dialog info: " & Dialog(dlg)
End Sub

Function DialogFunc%(DlgItem$, Action%, SuppValue%)
   Print "Action=";Action%
   Select Case Action%
      Case 1 ' Dialog box initialization
         Beep
      Case 2 ' Value changing Or button pressed
         If DlgItem$ = "Hello" Then
            MsgBox "Hello"
            DialogFunc% = True 'Do Not Exit the Dialog
         End If
      Case 4 ' Focus changed
         Print "DlgFocus=""";DlgFocus();""""
         MsgBox "DlgFocus info: " & DlgFocus() & """"
      End Select
End Function

Any help is greatly appreciated.

user692942
  • 16,398
  • 7
  • 76
  • 175
Steve R.
  • 15
  • 4
  • Not sure what this is probably some sort of hosted VBA but it most definitely is not VBScript. – user692942 Sep 07 '22 at 16:42
  • On second thought, it looks like [WordBasic](https://en.wikipedia.org/wiki/WordBASIC) with the `Begin` statement to define objects. – user692942 Sep 07 '22 at 16:45
  • This is a Cypress Enable VB scripting language for applications. – Steve R. Sep 07 '22 at 17:04
  • Can't say I've ever heard of it but from its description it's - "a VBA compatible scripting language". A bit confusing as "scripting" suggests VBScript but it's aimed at VBA compatibility so it would seem the VBA tag is the better fit. Ideally, the VBA tag should be accompanied by a "host" tag so VBA community members understand what flavour of VBA the question belongs to. – user692942 Sep 07 '22 at 18:02
  • Thank you for your response - I'm not sure what you mean though. Should I add "vba-host" or just "host" to the tag listing? – Steve R. Sep 07 '22 at 18:58
  • I’ve edited the tags, when I said "host" I meant the program that hosts VBA, in this case Cypress Enable. – user692942 Sep 07 '22 at 20:32

0 Answers0