Hi guys!
I was using a Sample Screensaver Framework from "zircher" (
http://forum.thegamecreators.com/?m=forum_view&t=35514&b=1) some time ago with Version 5.2 of DBPro. I wanted to continue some stuff and since i updated to 5.7 it always gives me this error:
Types '@in$'and " are incompatible at line 182.
Can anybody help me to fix this error?
Thanks
Rem Project: ScreenSaver
Rem Created: 11/12/2003
Rem ***** Main Source File *****
remstart
Windows SreenSaver Info:
ScreenSaver - Show the Settings dialog box.
ScreenSaver /c - Show the Settings dialog box,
modal to the foreground window.
ScreenSaver /p #### - Preview Screen Saver as child of window .
ScreenSaver /s - Run the Screen Saver.
ScreenSaver /a - Show the Password dialog box.
#### is a HWND presented on the command line as an unsigned decimal number.
You need to create the preview window as a child of this window. It should cover the parent's entire client area.
--
Well, that the theory. But the reality is a bit different. The /a switch is only called by Windows 95. Since you need DirectX 9.0b for DBPro 1.054, this is not even an option. Also, what is not covered in the Knowledge Base is that Windows XP adds more data to the /c option. It tends to look like this:
/c:123456 where 123456 is probably some windows handle.
Since Dark Basic Pro can not write to the /p handle, my solution is to create a separate preview window. I also do this for the configuration panel. There are other solutions, some developers use a VB or Delphi screen saver manager to handle configuration and lanching. While this works well and can handle the preview window problem, it requires a lot more file management. My solution creates a single executable (screensaver.scr) that you can drop into the main windows directory (ie. c:windows).
remend
global gPreview
global gPlayMusic
global gResolutionX
global gResolutionY
global gINIfile$
rem read in INI file or create one if not present
gINIfile$ = "ScreenSaver.ini"
readINIfile(gINIfile$)
rem get the command switch only and convert it to lower case
in$ = lower$(left$(cl$(),2))
rem default to config mode if /s or /p is not present
select in$
case "/s": rem run in normal/test mode
set window on
set window layout 0,0,1
set display mode gResolutionX, gResolutionY, 32
goto _start
endCase
case "/p": rem run in preview mode
if gPreview = 1 then end
set window on
set display mode 320,240,32
set window position 100,100
set window title "Screen Saver Preview Window"
goto _start
endCase
case default: rem display config options
set window on
set display mode 320,240,32
set window position 100,100
set window title "Screen Saver Settings"
color backdrop 0, 0
set text size 20
set text to bold
rem set ink to yellow
ink rgb(255,255,0),0
sync off
sync rate 40
rem clear our 'radio' buttons with double spaces
radioA$=" ": radioB$=" ": radioC$=" ": radioD$=" ": radioE$=" "
rem set the values that are active
if gPreview = 1 then radioA$="X"
if gResolutionX = 640 then radioB$="X"
if gResolutionX = 800 then radioC$="X"
if gResolutionX = 1024 then radioD$="X"
if gPlayMusic = 1 then radioE$="X"
rem main config loop
do
cls
rem no functional value, I just like the yellow border
line 0,0,0,239
line 0,239,319,239
line 319,239,319,0
line 319,0,0,0
rem display them menu
text 20,40, "["+radioA$+"]": text 60,40, "Disable Preview Window"
text 20,80, "["+radioB$+"]": text 60,80, "640x480 mode"
text 20,120, "["+radioC$+"]": text 60,120, "800x600 mode"
text 20,160, "["+radioD$+"]": text 60,160, "1024x768 mode"
text 20,200, "["+radioE$+"]": text 60,200, "Play Music"
mx = mousex()
my = mousey()
rem the mouse delay prevents 'over clicking' on a menu item
if mouseclick() = 1 and mouseDelay < timer()
rem half second delay
mouseDelay = timer()+500
rem check each line for a mouse location
rem the user can click on the 'button' or the text
if my >= 40 and my<=60
if radioA$="X"
radioA$=" ": gPreview = 0
else
radioA$="X": gPreview = 1
endif
endif
if my >= 80 and my<=100
radioB$="X"
radioC$=" "
radioD$=" "
gResolutionX = 640
gResolutionY = 480
endif
if my >= 120 and my<=140
radioB$=" "
radioC$="X"
radioD$=" "
gResolutionX = 800
gResolutionY = 600
endif
if my >= 160 and my<=180
radioB$=" "
radioC$=" "
radioD$="X"
gResolutionX = 1024
gResolutionY = 768
endif
if my >= 200 and my<=220
if radioE$="X"
radioE$=" ": gPlayMusic = 0
else
radioE$="X": gPlayMusic = 1
endif
endif
rem always save the INI file in the same place
INIfile$ = WINDIR$() +""+ gINIfile$
rem delete old file
if file exist(INIfile$)=1 then delete file (INIfile$)
rem save changes
open to write 1, INIfile$
write string 1, "[ScreenSaver]"
write string 1, "Preview="+ str$(gPreview)
write string 1, "PlayMusic="+ str$(gPlayMusic)
write string 1, "ResolutionX="+ str$(gResolutionX)
write string 1, "ResolutionY="+ str$(gResolutionY)
close file 1
endif
sync
loop
endCase
endSelect
_start: rem main initialization begins here
color backdrop 0, 0
load object "mediainverted_sphere.x", 1
scale object 1, 10000,10000,10000
load object "mediako_ship.x", 2
scale object 2, .5,.5,.5
yrotate object 2, 180
fix object pivot 2
set object light 2, 1
sync on
sync rate 0
set normalization on
DISABLE ESCAPEKEY
rem leave the mouse visible in preview mode
if not in$="/p" then hide mouse
rem parameters used to control the camera that follows/orbits the model
cameraAngle# = 180.0
cameraDistance# = 10.0
cameraHeight# = 2.0
cameraSmooth# = 10.0
rem yellow ink
ink rgb(255,255,0),0
set text font "Arial"
set text size 24
rem load and play music, if enabled and not in preview mode
if in$ <> "/p" and gPlayMusic = 1
load music "mediatrack1.mp3", 1
loop music 1
endif
rem banner text offset
textY = screen height() - 70
rem used to track when to remove the banner
startTime = timer()
rem used to create smooth motion since screen fps() is unreliable
oldTime = timer()
newTime = 0
rem original mouse location
oldx = mousex()
oldy = mousey()
do
rem display a yellow border in preview mode
if in$ = "/p"
line 0,0,0,239
line 0,239,319,239
line 319,239,319,0
line 319,0,0,0
endif
mx = mousex()
my = mousey()
rem get the new elapsed time
newTime = timer()-oldTime
oldTime = timer()
REM ***** Your screen saver coding begins here. *****
rem allow the arrow keys to be active so we can play with the model
arrowKeysActive = 0
if rightkey()
arrowKeysActive = 1
roll object right 2, (20.0/newTime)
endif
if leftkey()
arrowKeysActive = 1
roll object left 2, (20.0/newTime)
endif
if upkey()
arrowKeysActive = 1
pitch object up 2, (20.0/newTime)
endif
if downkey()
arrowKeysActive = 1
pitch object down 2, (20.0/newTime)
endif
if arrowKeysActive = 0
rem abort on most keypresses or mouse movement
if scancode() > 0 then goto _end
if mx <> oldx and my <> oldy then goto _end
endif
rem update the camera location
set camera to follow 0, object position x(2),object position y(2),object position z(2), cameraAngle#, cameraDistance#, cameraHeight#, cameraSmooth#, 0
rem continue updating the camera rotation value
cameraAngle# = cameraAngle# + (20.0/(screen fps()+1))
cameraAngle# = wrapvalue(cameraAngle#)
REM ***** Your screen saver coding ends here. *****
rem display the banner if it would be visible
if textY <= screen height()
text 10, textY, "Dark Tangent: Killer Angels"
text 10, textY+20, "music: Chaos Gate Ultramarines"
text 10, textY+40, "program: Todd A. Zircher (TAZ)"
rem scroll text after 10 second delay
if startTime+ 10000 < timer() then textY = textY +1
endif
sync
loop
rem restore mouse pointer and exit
_end:
if not in$="/p" then show mouse
end
function readINIfile(INIfile$ as string)
rem default values in case INI is not found or has errors
gPreview = 0
gPlayMusic = 1
gResolutionX = 640
gResolutionY = 480
rem set the path to the Windows directory
INIfile$ = WINDIR$() +""+ INIfile$
if file exist(INIfile$)=1
rem read values
open to read 1, INIfile$
read string 1, inStr$
while inStr$ <> ""
if left$(inStr$,8) = "Preview=" then gPreview = val(right$(inStr$,len(inStr$)-8))
if left$(inStr$,10) = "PlayMusic=" then gPlayMusic = val(right$(inStr$,len(inStr$)-10))
if left$(inStr$,12) = "ResolutionX=" then gResolutionX = val(right$(inStr$,len(inStr$)-12))
if left$(inStr$,12) = "ResolutionY=" then gResolutionY = val(right$(inStr$,len(inStr$)-12))
read string 1, inStr$
endwhile
close file 1
else
rem create an INI file for future use
open to write 1, INIfile$
write string 1, "[ScreenSaver]"
write string 1, "Preview="+ str$(gPreview)
write string 1, "PlayMusic="+ str$(gPlayMusic)
write string 1, "ResolutionX="+ str$(gResolutionX)
write string 1, "ResolutionY="+ str$(gResolutionY)
close file 1
endif
endFunction